grpc

package
v0.6.4 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package grpc provides gRPC-based plugin runtime using HashiCorp go-plugin.

This enables native Go plugins to run as separate processes, communicating with the host via gRPC. Useful for I/O-heavy plugins that benefit from native performance and direct system access.

Index

Constants

This section is empty.

Variables

View Source
var Handshake = goplugin.HandshakeConfig{
	ProtocolVersion:  1,
	MagicCookieKey:   "GOATKIT_PLUGIN",
	MagicCookieValue: "goatkit-v1",
}

Handshake is the shared handshake config for host and plugins. Plugins must use the same values to connect.

View Source
var PluginMap = map[string]goplugin.Plugin{
	"gkplugin": &GKPluginPlugin{},
}

PluginMap is the map of plugin types we support.

Functions

func ServePlugin

func ServePlugin(impl GKPluginInterface)

ServePlugin is called by plugin executables to serve the plugin. Plugin main() should call this with their implementation.

Types

type CallRequest

type CallRequest struct {
	Function string
	Args     json.RawMessage
}

CallRequest is the RPC request for Call.

type CallResponse

type CallResponse struct {
	Result json.RawMessage
	Error  string
}

CallResponse is the RPC response for Call.

type GKPluginInterface

type GKPluginInterface interface {
	GKRegister() (*plugin.GKRegistration, error)
	Init(config map[string]string) error
	Call(fn string, args json.RawMessage) (json.RawMessage, error)
	Shutdown() error
}

GKPluginInterface is the interface that gRPC plugins implement. This is the RPC interface - the actual implementation runs in the plugin process.

type GKPluginPlugin

type GKPluginPlugin struct {
	goplugin.Plugin
	Impl GKPluginInterface
}

GKPluginPlugin is the go-plugin.Plugin implementation.

func (*GKPluginPlugin) Client

func (p *GKPluginPlugin) Client(b *goplugin.MuxBroker, c *rpc.Client) (interface{}, error)

Client returns the RPC client for the plugin (host side).

func (*GKPluginPlugin) Server

func (p *GKPluginPlugin) Server(*goplugin.MuxBroker) (interface{}, error)

Server returns the RPC server for the plugin (plugin side).

type GKPluginRPCClient

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

GKPluginRPCClient is the RPC client implementation (host side).

func (*GKPluginRPCClient) Call

func (*GKPluginRPCClient) GKRegister

func (c *GKPluginRPCClient) GKRegister() (*plugin.GKRegistration, error)

func (*GKPluginRPCClient) Init

func (c *GKPluginRPCClient) Init(config map[string]string) error

func (*GKPluginRPCClient) Shutdown

func (c *GKPluginRPCClient) Shutdown() error

type GKPluginRPCServer

type GKPluginRPCServer struct {
	Impl GKPluginInterface
}

GKPluginRPCServer is the RPC server implementation (plugin side).

func (*GKPluginRPCServer) Call

func (s *GKPluginRPCServer) Call(req CallRequest, resp *CallResponse) error

func (*GKPluginRPCServer) GKRegister

func (s *GKPluginRPCServer) GKRegister(args interface{}, resp *plugin.GKRegistration) error

func (*GKPluginRPCServer) Init

func (s *GKPluginRPCServer) Init(config map[string]string, resp *interface{}) error

func (*GKPluginRPCServer) Shutdown

func (s *GKPluginRPCServer) Shutdown(args interface{}, resp *interface{}) error

type GRPCPlugin

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

GRPCPlugin wraps a go-plugin client to implement plugin.Plugin.

func LoadGRPCPlugin

func LoadGRPCPlugin(execPath string, host plugin.HostAPI) (*GRPCPlugin, error)

LoadGRPCPlugin loads a gRPC plugin from an executable path.

func (*GRPCPlugin) Call

func (p *GRPCPlugin) Call(ctx context.Context, fn string, args json.RawMessage) (json.RawMessage, error)

Call implements plugin.Plugin.

func (*GRPCPlugin) GKRegister

func (p *GRPCPlugin) GKRegister() plugin.GKRegistration

GKRegister implements plugin.Plugin.

func (*GRPCPlugin) Init

func (p *GRPCPlugin) Init(ctx context.Context, host plugin.HostAPI) error

Init implements plugin.Plugin.

func (*GRPCPlugin) Shutdown

func (p *GRPCPlugin) Shutdown(ctx context.Context) error

Shutdown implements plugin.Plugin.

Directories

Path Synopsis
Example gRPC plugin for GoatKit.
Example gRPC plugin for GoatKit.

Jump to

Keyboard shortcuts

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