grpc

package
v0.0.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package grpc provides gRPC-based plugin client implementation. It handles communication with plugins using gRPC protocol, including process management, socket file handling, and request/response conversion.

Package plugininterface provides utility functions for plugin implementations. It includes helper functions for type conversion and data manipulation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client represents a gRPC plugin client. It manages the lifecycle of a plugin process and handles communication via gRPC.

func NewClient

func NewClient(pluginPath string, config map[string]any) (*Client, error)

NewClient creates a new gRPC plugin client. It sets up a temporary directory for the socket file and starts the plugin process. The pluginPath parameter specifies the path to the plugin executable. Returns a new Client instance and an error if initialization fails.

func (*Client) Close

func (c *Client) Close(ctx context.Context) error

Close terminates the plugin process and cleans up resources. It sends a shutdown request to the plugin and waits for it to terminate. The context can be used for cancellation and timeout control. Returns an error if cleanup fails.

func (*Client) GetMetadata

func (c *Client) GetMetadata(ctx context.Context, entry *model.DomainEntry, dehydratedConfig *dehydrated.Config) (map[string]any, error)

GetMetadata retrieves metadata for a domain entry from the plugin. It converts the domain entry to protobuf format and sends it to the plugin. The context can be used for cancellation and timeout control. Returns a map of metadata key-value pairs and an error if the operation fails.

func (*Client) Initialize

func (c *Client) Initialize(ctx context.Context, config map[string]any) error

Initialize initializes the plugin with the provided configuration. It converts the configuration to protobuf format and sends it to the plugin. The context can be used for cancellation and timeout control. Returns an error if initialization fails.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL