Documentation
¶
Index ¶
- Variables
- func HandleLoadPluginRpc(b bus.Bus, req *bldr_plugin.LoadPluginRequest, ...) error
- type LoadPluginResolver
- type LookupPluginHost
- type LookupPluginHostValue
- type PluginHost
- type PluginHostScheduler
- type PluginHostServer
- func (s *PluginHostServer) ExecController(req *controller_exec.ExecControllerRequest, ...) error
- func (s *PluginHostServer) GetPluginInfo(ctx context.Context, req *bldr_plugin.GetPluginInfoRequest) (*bldr_plugin.GetPluginInfoResponse, error)
- func (s *PluginHostServer) LoadPlugin(req *bldr_plugin.LoadPluginRequest, ...) error
- func (s *PluginHostServer) PluginFsRpc(rpcStream bldr_plugin.SRPCPluginHost_PluginFsRpcStream) error
- func (s *PluginHostServer) PluginRpc(strm bldr_plugin.SRPCPluginHost_PluginRpcStream) error
- type PluginRpcInitCb
Constants ¶
This section is empty.
Variables ¶
var ErrPluginUninitialized = errors.New("plugin is not yet initialized")
ErrPluginUninitialized is returned if the plugin was not initialized.
Functions ¶
func HandleLoadPluginRpc ¶
func HandleLoadPluginRpc( b bus.Bus, req *bldr_plugin.LoadPluginRequest, strm bldr_plugin.SRPCPluginHost_LoadPluginStream, ) error
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 ¶
func (r *LoadPluginResolver) Resolve(ctx context.Context, handler directive.ResolverHandler) error
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 ¶
func (s *PluginHostServer) ExecController( req *controller_exec.ExecControllerRequest, strm bldr_plugin.SRPCPluginHost_ExecControllerStream, ) error
ExecController executes a config set on the host bus.
func (*PluginHostServer) GetPluginInfo ¶
func (s *PluginHostServer) GetPluginInfo( ctx context.Context, req *bldr_plugin.GetPluginInfoRequest, ) (*bldr_plugin.GetPluginInfoResponse, error)
GetPluginInfo returns information about the currently running plugin.
func (*PluginHostServer) LoadPlugin ¶
func (s *PluginHostServer) LoadPlugin( req *bldr_plugin.LoadPluginRequest, strm bldr_plugin.SRPCPluginHost_LoadPluginStream, ) error
LoadPlugin requests to send a LoadPlugin directive.
func (*PluginHostServer) PluginFsRpc ¶
func (s *PluginHostServer) PluginFsRpc(rpcStream bldr_plugin.SRPCPluginHost_PluginFsRpcStream) error
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 ¶
func (s *PluginHostServer) PluginRpc(strm bldr_plugin.SRPCPluginHost_PluginRpcStream) error
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 ¶
PluginRpcInitCb is a callback to be called when the RPC channel is ready.