Documentation
¶
Overview ¶
Package command dispatches plugin-specific opaque command payloads through optional RPC transport.
Index ¶
Constants ¶
const (
// PluginID is the go-plugin capability name used to dispense command transport.
PluginID = "command"
)
Variables ¶
var ( // ErrHandlerNotFound is returned when a handler is not found. ErrHandlerNotFound = errors.New("handler not found") // ErrHandlerTimeout is returned when a handler times out. ErrHandlerTimeout = errors.New("handler timeout") )
Functions ¶
func RegisterPlugin ¶
func RegisterPlugin( p *sdk.Plugin, opts PluginOpts, ) error
RegisterPlugin installs handlers as a command capability; a nil plugin returns an error.
Types ¶
type Handler ¶
type Handler func(ctx *types.PluginContext, body []byte) ([]byte, error)
Handler is a function that processes a command called from the frontend. It is expected to return the response body as a byte slice.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager dispatches commands through a handler map shared with its constructor.
func NewManager ¶
NewManager retains handlers without copying. Do not mutate the map during calls. A nil logger disables logging; handlers own any synchronization they need.
type Plugin ¶
Plugin registers command RPCs or creates a client for a go-plugin connection.
func (*Plugin) GRPCClient ¶
func (p *Plugin) GRPCClient( _ context.Context, _ *plugin.GRPCBroker, c *grpc.ClientConn, ) (any, error)
GRPCClient returns a command client using the supplied connection.
func (*Plugin) GRPCServer ¶
GRPCServer installs command RPCs backed by Impl.
type PluginClient ¶
type PluginClient struct {
// contains filtered or unexported fields
}
PluginClient forwards commands over a shared gRPC client connection.
func (*PluginClient) Call ¶
func (p *PluginClient) Call( ctx *types.PluginContext, path string, body []byte, ) ([]byte, error)
Call forwards a command with request metadata. RPC lifetime uses a background context; cancellation in the supplied PluginContext does not cancel this legacy transport.
type PluginOpts ¶
PluginOpts contains the options for the command plugin.
type PluginServer ¶
type PluginServer struct {
Impl Provider
}
PluginServer adapts command RPCs to Impl without retaining request payloads.
func (*PluginServer) Call ¶
func (s *PluginServer) Call( ctx context.Context, req *commandpb.CallCommandRequest, ) (*commandpb.CallCommandResponse, error)
Call requires plugin context and dispatches the requested path. Handler failures become Internal RPC errors; missing context becomes InvalidArgument.