Documentation
¶
Overview ¶
Package plugin provides an executor which uses go-plugin to launch gRPC subprocesses.
Index ¶
- type Plugin
- func (p *Plugin) Execute(ctx context.Context, session task.Session, tsk *task.Task, res *task.Result) error
- func (*Plugin) GRPCClient(context.Context, *goplugin.GRPCBroker, *grpc.ClientConn) (any, error)
- func (p *Plugin) GRPCServer(_ *goplugin.GRPCBroker, server *grpc.Server) error
- func (p *Plugin) Name() string
- func (p *Plugin) Serve()
- func (plugin *Plugin) ServeTest(t *testing.T) executor.Executor
- type PluginClient
- type PluginClientManager
- type PluginOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Plugin ¶
type Plugin struct {
router.Router
goplugin.NetRPCUnsupportedPlugin
// contains filtered or unexported fields
}
Plugin describes a plugin and the services it provides.
func NewPlugin ¶
func NewPlugin(name string, initializers ...PluginOption) *Plugin
NewPlugin creates a new Plugin from the given options.
func (*Plugin) Execute ¶
func (p *Plugin) Execute( ctx context.Context, session task.Session, tsk *task.Task, res *task.Result, ) error
Execute adds some special details to the context.
func (*Plugin) GRPCClient ¶
func (*Plugin) GRPCClient( context.Context, *goplugin.GRPCBroker, *grpc.ClientConn, ) (any, error)
GRPCClient is unsupported.
func (*Plugin) GRPCServer ¶
GRPCServer calls rpc.RegisterGRPCServer for the plugin.
type PluginClient ¶
PluginClient manages a goplugin.Client and exposes it as a executor.Executor.
func NewPluginClient ¶
func NewPluginClient(ctx context.Context, goCmdPath string) (*PluginClient, error)
NewPluginClient starts a plugin subprocess and opens a gRPC connection to it.
func (*PluginClient) Shutdown ¶
func (plugin *PluginClient) Shutdown()
Shutdown kills the subprocess.
type PluginClientManager ¶
type PluginClientManager interface {
executor.Executor
// NOTE(colden): these should eventually be moved out of here
RegisterExecutor(name string, exec executor.Executor) error
UnregisterExecutors(names ...string)
StartPlugins(ctx context.Context, plugins ...string) error
Shutdown(ctx context.Context)
}
PluginClientManager manages a set of [PluginClient]s and functions as a distributing router.Router.
func NewPluginClientManager ¶
func NewPluginClientManager() PluginClientManager
NewPluginClientManager creates a new empty PluginClientManager.
type PluginOption ¶
PluginOption is a modifier for the plugin.
func WithExecutor ¶
func WithExecutor[Params any](name string, exec argconv.TypedExecutor[Params]) PluginOption
WithExecutor registers an executor with the plugin.