Help us shape the future of Go! Take the 2026 Go Developer Survey

plugin_host

package
v0.57.14 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrPluginUninitialized = errors.New("plugin is not yet initialized")

ErrPluginUninitialized is returned if the plugin was not initialized.

Functions

func HandleLoadPluginRpc

HandleLoadPluginRpc handles an incoming LoadPlugin RPC request.

Types

type LoadPluginResolver

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

LoadPluginResolver resolves LoadPlugin with the controller.

func NewLoadPluginResolver

func NewLoadPluginResolver(c PluginHostScheduler, pluginID, instanceKey, manifestRoot string, selected []*manifest.ManifestRef) *LoadPluginResolver

NewLoadPluginResolver constructs a new LoadPluginResolver.

func (*LoadPluginResolver) Resolve

Resolve resolves the values, emitting them to the handler.

type LookupPluginHost

type LookupPluginHost interface {
	// Directive indicates LookupPluginHost is a directive.
	directive.Directive

	// LookupPluginHostPlatformIDs filters the platform IDs to match.
	// If unset (empty), matches all platform IDs.
	LookupPluginHostPlatformIDs() []string
}

LookupPluginHost is a directive to look up available plugin hosts on the bus.

func NewLookupPluginHost

func NewLookupPluginHost(platformIDs []string) LookupPluginHost

NewLookupPluginHost constructs a new LookupPluginHost directive.

type LookupPluginHostValue

type LookupPluginHostValue = PluginHost

LookupPluginHostValue is the result type for LookupPluginHost. Multiple results may be pushed to the directive.

func ExLookupPluginHostByPlatform

func ExLookupPluginHostByPlatform(
	ctx context.Context,
	b bus.Bus,
	returnIfIdle bool,
	platformID string,
	valDisposeCallback func(),
) (LookupPluginHostValue, directive.Instance, directive.Reference, error)

ExLookupPluginHostByPlatform executes the LookupPluginHost directive for a single platform ID.

if returnIfIdle=true and the directive becomes idle, returns nil, nil, nil

type PluginHost

type PluginHost interface {
	// GetPlatformId returns the platform ID for this host.
	// The plugin host must be capable of executing plugin manifests with this platform id.
	// Must return a value.
	GetPlatformId() string

	// Execute executes the plugin host.
	// If an error is returned, the plugin host execution will be retried.
	// If nil is returned, this indicates PluginHost does not need the Execute goroutin.
	// Return context.Canceled if context was canceled.
	Execute(ctx context.Context) error

	// ListPlugins lists the set of loaded plugins in the host.
	ListPlugins(ctx context.Context) ([]string, error)

	// ExecutePlugin executes the plugin with the given ID.
	// If the plugin was already initialized, existing state can be reused.
	// The plugin should be stopped if/when the function exits.
	// Return ErrPluginUninitialized if the plugin was not ready.
	// Should expect to be called only once (at a time) for a plugin ID.
	// pluginDist contains the plugin distribution files (binaries and assets).
	// rpcInit is called when the RPC client is ready, should return a mux for the server.
	// instanceKey is the logical instance key passed to the plugin in its start
	// info (empty for shared plugins).
	// executionKey distinguishes concurrent executions of one instance, such
	// as a replacement starting before its predecessor stops. Hosts derive
	// worker and controller identities from it.
	// manifestRoot identifies the exact files used by this execution.
	ExecutePlugin(
		ctx context.Context,
		pluginID,
		instanceKey,
		executionKey,
		manifestRoot,
		entrypoint string,
		pluginDist *unixfs.FSHandle,
		pluginAssets *unixfs.FSHandle,
		hostRpcMux srpc.Mux,
		rpcInit PluginRpcInitCb,
	) error

	// DeletePlugin clears cached plugin data for the given plugin ID.
	DeletePlugin(ctx context.Context, pluginID string) error
}

PluginHost manages and executes plugins.

type PluginHostScheduler

type PluginHostScheduler interface {
	// AddPluginReference adds a reference to the plugin, returning the RunningPlugin
	// handle and a release function.
	// instanceKey may be empty for shared (non-instanced) plugins.
	AddPluginReference(pluginID, instanceKey string) (bldr_plugin.RunningPluginRef, func())

	// AddPinnedPluginReference retains an exact executable without following replacement.
	AddPinnedPluginReference(pluginID, instanceKey, manifestRoot string) (bldr_plugin.RunningPluginRef, func())

	// AddSelectedPluginReference selects an installed artifact for a logical binding.
	AddSelectedPluginReference(pluginID, instanceKey string, refs ...*manifest.ManifestRef) (bldr_plugin.RunningPluginRef, func())
}

PluginHostScheduler manages the PluginHosts and running plugins.

type PluginHostServer

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

PluginHostServer implements the PluginHost rpc service

func NewPluginHostServer

func NewPluginHostServer(
	ctx context.Context,
	b bus.Bus,
	le *logrus.Entry,
	pluginID string,
	instanceKey string,
	manifest *bldr_manifest.ManifestSnapshot,
	hostVolumeInfo *volume.VolumeInfo,
	hostStorageID string,
	historical bool,
) *PluginHostServer

NewPluginHostServer constructs a new PluginHostServer.

func (*PluginHostServer) ExecController

ExecController executes a config set on the host bus.

func (*PluginHostServer) GetPluginInfo

GetPluginInfo returns information about the currently running plugin.

func (*PluginHostServer) LoadPlugin

LoadPlugin requests to send a LoadPlugin directive.

func (*PluginHostServer) PluginFsRpc

PluginFsRpc accesses a FSCursorService to access the plugin assets or dist filesystems. The plugin will remain loaded as long as the RPC is active. Component ID: plugin-assets or plugin-dist

func (*PluginHostServer) PluginRpc

PluginRpc forwards an RPC call to a remote plugin. The plugin will remain loaded as long as the RPC is active. Component ID: plugin id, or plugin id / instance key for instanced plugins.

func (*PluginHostServer) SetPluginScheduler

func (s *PluginHostServer) SetPluginScheduler(scheduler bldr_plugin.PluginScheduler)

SetPluginScheduler sets the host scheduler whose status WatchPluginStatus streams. Set it before exposing this server to its plugin.

func (*PluginHostServer) SetPrepared

func (s *PluginHostServer) SetPrepared(prepared bool)

SetPrepared requests private registration until explicit candidate admission.

func (*PluginHostServer) SetRegistrationInstanceKey

func (s *PluginHostServer) SetRegistrationInstanceKey(instanceKey string)

SetRegistrationInstanceKey binds registrations to the logical installation. Set it before exposing this server to its plugin.

func (*PluginHostServer) WatchPluginStatus

WatchPluginStatus streams the host scheduler's plugin status.

type PluginRpcInitCb

type PluginRpcInitCb func(client srpc.Client) error

PluginRpcInitCb is a callback to be called when the RPC channel is ready.

Directories

Path Synopsis
Package plugin_host_logs contains structured plugin log schema types.
Package plugin_host_logs contains structured plugin log schema types.
Package plugin_host_mock provides plugin host test doubles.
Package plugin_host_mock provides plugin host test doubles.
Package plugin_host_static resolves LookupPluginHost with a fixed set of plugin hosts that another component runs.
Package plugin_host_static resolves LookupPluginHost with a fixed set of plugin hosts that another component runs.
gen command

Jump to

Keyboard shortcuts

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