plugin_host

package
v0.51.2 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: Apache-2.0 Imports: 21 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 string) *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 instance key for instanced plugins (empty for shared).
	ExecutePlugin(
		ctx context.Context,
		pluginID,
		instanceKey,
		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())
}

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,
	manifest *bldr_manifest.ManifestSnapshot,
	hostVolumeInfo *volume.VolumeInfo,
) *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.

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
gen command

Jump to

Keyboard shortcuts

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