plugin

package
v0.0.0-...-6fa5d2c Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2026 License: MIT Imports: 20 Imported by: 0

README

plugin

import "go.bonk.build/pkg/executor/plugin"

Package plugin provides an executor which uses go-plugin to launch gRPC subprocesses.

Index

type Plugin

Plugin describes a plugin and the services it provides.

type Plugin struct {
    router.Router
    goplugin.NetRPCUnsupportedPlugin
    // contains filtered or unexported fields
}

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
func (p *Plugin) GRPCServer(_ *goplugin.GRPCBroker, server *grpc.Server) error

GRPCServer calls [rpc.RegisterGRPCServer] for the plugin.

func (*Plugin) Name
func (p *Plugin) Name() string

Name returns the plugin's name.

func (*Plugin) Serve
func (p *Plugin) Serve()

Serve starts the plugin gRPC server.

func (*Plugin) ServeTest
func (plugin *Plugin) ServeTest(t *testing.T) executor.Executor

ServeTest sets up a test gRPC connection which serves plugin and returns a client executor.

type PluginClient

PluginClient manages a [goplugin.Client] and exposes it as a [executor.Executor].

type PluginClient struct {
    executor.Executor
    // contains filtered or unexported fields
}

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

PluginClientManager manages a set of [PluginClient]s and functions as a distributing [router.Router].

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)
}

func NewPluginClientManager
func NewPluginClientManager() PluginClientManager

NewPluginClientManager creates a new empty PluginClientManager.

type PluginOption

PluginOption is a modifier for the plugin.

type PluginOption func(plugin *Plugin) error

func WithExecutor
func WithExecutor[Params any](name string, exec argconv.TypedExecutor[Params]) PluginOption

WithExecutor registers an executor with the plugin.

Generated by gomarkdoc

Documentation

Overview

Package plugin provides an executor which uses go-plugin to launch gRPC subprocesses.

Index

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

func (p *Plugin) GRPCServer(_ *goplugin.GRPCBroker, server *grpc.Server) error

GRPCServer calls rpc.RegisterGRPCServer for the plugin.

func (*Plugin) Name

func (p *Plugin) Name() string

Name returns the plugin's name.

func (*Plugin) Serve

func (p *Plugin) Serve()

Serve starts the plugin gRPC server.

func (*Plugin) ServeTest

func (plugin *Plugin) ServeTest(t *testing.T) executor.Executor

ServeTest sets up a test gRPC connection which serves plugin and returns a client executor.

type PluginClient

type PluginClient struct {
	executor.Executor
	// contains filtered or unexported fields
}

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

type PluginOption func(plugin *Plugin) error

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.

Jump to

Keyboard shortcuts

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