Documentation
¶
Index ¶
- Constants
- type BuildOpts
- type CapabilityDetector
- type ConnectedController
- type Controller
- type ExternalBackend
- func (b *ExternalBackend) DetectCapabilities() ([]string, error)
- func (b *ExternalBackend) Dispense(name string) (interface{}, error)
- func (b *ExternalBackend) Exited() bool
- func (b *ExternalBackend) Healthy() bool
- func (b *ExternalBackend) Kill()
- func (b *ExternalBackend) NegotiatedVersion() int
- func (b *ExternalBackend) ReattachConfig() *goplugin.ReattachConfig
- func (b *ExternalBackend) Stop() error
- type InProcessBackend
- func (b *InProcessBackend) DetectCapabilities() ([]string, error)
- func (b *InProcessBackend) Dispense(name string) (interface{}, error)
- func (b *InProcessBackend) Exited() bool
- func (b *InProcessBackend) Healthy() bool
- func (b *InProcessBackend) Kill()
- func (b *InProcessBackend) NegotiatedVersion() int
- func (b *InProcessBackend) Stop() error
- type PluginBackend
- type PluginManager
- type PluginManagerConfig
- type PluginRecord
- type PluginStateRecord
Constants ¶
const CurrentProtocolVersion = 1
CurrentProtocolVersion is the latest SDK protocol version supported by the engine. Bump this when adding a new protocol version.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BuildOpts ¶
type BuildOpts struct {
// ExcludeBackend tells the builder to not build the plugin binary. This is useful
// when we only have changes to UI components.
ExcludeBackend bool
// ExcludeUI tells the builder to not rebuild the plugin UI. This is useful
// when we only have changes to the plugin binary.
ExcludeUI bool
// GoPath defines a predefined path to the Go binary
GoPath string
// PnpmPath defines a predefined path to the PNPM binary
PnpmPath string
// NodePath defines a predefined path to the Node binary
NodePath string
}
BuildOpts specifies how a plugin should be built.
type CapabilityDetector ¶ added in v0.1.4
CapabilityDetector is an optional interface that backends can implement to report which capabilities they support.
type ConnectedController ¶
type ConnectedController interface {
Controller
// ListAllConnections returns a list of all connections for all plugins.
ListAllConnections() (map[string][]types.Connection, error)
// GetConnection returns a connection for a plugin by ID.
GetConnection(pluginID, connectionID string) (types.Connection, error)
// GetConnectionNamespaces returns a list of connection namespaces for a plugin.
GetConnectionNamespaces(pluginID, connectionID string) ([]string, error)
// ListPluginConnections returns a list of connections for the plugin.
ListConnections(pluginID string) ([]types.Connection, error)
// AddConnection adds a new connection for the plugin.
AddConnection(pluginID string, connection types.Connection) error
// UpdateConnection updates an existing connection for a plugin
UpdateConnection(pluginID string, connection types.Connection) (types.Connection, error)
// RemoveConnection removes a connection for a plugin
RemoveConnection(pluginID, connectionID string) error
// Run starts the controller, using the provided context to know when to stop
Run(ctx context.Context)
}
ConnectedControllers work with plugins that have connections to backend resources. This is a superset of the Controller interface, with additional requirements for when events relating to connections occur.
type Controller ¶
type Controller interface {
// OnPluginInit is called after the plugin is loaded in to do any pre-startup initialization.
OnPluginInit(pluginID string, meta config.PluginMeta)
// OnPluginStart is called when the plugin is started.
OnPluginStart(pluginID string, meta config.PluginMeta, backend PluginBackend) error
// OnPluginStop is called when the plugin is stopped. Modules should perform any persisting of state here
OnPluginStop(pluginID string, meta config.PluginMeta) error
// OnPluginShutdown is called when the plugin is shutdown. This is the last chance to clean up any resources
// before the IDE is closed.
OnPluginShutdown(pluginID string, meta config.PluginMeta) error
// OnPluginDestroy is called when the plugin is being removed from the system. This is the last chance to
// clean up any resources associated with the plugin before it is uninstalled.
OnPluginDestroy(pluginID string, meta config.PluginMeta) error
// ListPlugins returns a list of names of the plugins that are installed.
ListPlugins() ([]string, error)
// HasPlugin returns true if the plugin is registered with this controller.
HasPlugin(pluginID string) bool
}
Controller manages the lifecycle of a plugin type. Controllers can embed many managers to take care of different tasks, but at the base must implement the Controller interface.
type ExternalBackend ¶ added in v0.1.4
type ExternalBackend struct {
// contains filtered or unexported fields
}
ExternalBackend wraps a go-plugin Client and ClientProtocol pair. All go-plugin concrete types are confined to this file.
func NewExternalBackend ¶ added in v0.1.4
func NewExternalBackend(pluginClient *goplugin.Client, rpcClient goplugin.ClientProtocol) *ExternalBackend
NewExternalBackend creates a new ExternalBackend wrapping go-plugin types.
func (*ExternalBackend) DetectCapabilities ¶ added in v0.1.4
func (b *ExternalBackend) DetectCapabilities() ([]string, error)
DetectCapabilities tries lifecycle-based detection first, then falls back to gRPC method probing.
func (*ExternalBackend) Dispense ¶ added in v0.1.4
func (b *ExternalBackend) Dispense(name string) (interface{}, error)
Dispense returns a capability client by name.
func (*ExternalBackend) Exited ¶ added in v0.1.4
func (b *ExternalBackend) Exited() bool
Exited returns true if the plugin process has exited.
func (*ExternalBackend) Healthy ¶ added in v0.1.4
func (b *ExternalBackend) Healthy() bool
Healthy checks plugin health via lifecycle RPC, falling back to process exit status.
func (*ExternalBackend) Kill ¶ added in v0.1.4
func (b *ExternalBackend) Kill()
Kill forcefully terminates the plugin process.
func (*ExternalBackend) NegotiatedVersion ¶ added in v0.2.0
func (b *ExternalBackend) NegotiatedVersion() int
NegotiatedVersion returns the SDK protocol version negotiated via go-plugin.
func (*ExternalBackend) ReattachConfig ¶ added in v0.1.4
func (b *ExternalBackend) ReattachConfig() *goplugin.ReattachConfig
ReattachConfig exposes the plugin process PID for the PID tracker.
func (*ExternalBackend) Stop ¶ added in v0.1.4
func (b *ExternalBackend) Stop() error
Stop gracefully closes the RPC connection.
type InProcessBackend ¶ added in v0.1.4
type InProcessBackend struct {
// HealthFunc optionally overrides the default health check.
// If nil, Healthy() returns !stopped.
HealthFunc func() bool
// contains filtered or unexported fields
}
InProcessBackend serves as both the test backend and the future bundled plugin backend. Providers are registered by name and dispensed directly without any gRPC or process boundary.
func NewInProcessBackend ¶ added in v0.1.4
func NewInProcessBackend(providers map[string]interface{}) *InProcessBackend
NewInProcessBackend creates a new InProcessBackend with the given providers.
func (*InProcessBackend) DetectCapabilities ¶ added in v0.1.4
func (b *InProcessBackend) DetectCapabilities() ([]string, error)
DetectCapabilities returns the names of all registered providers.
func (*InProcessBackend) Dispense ¶ added in v0.1.4
func (b *InProcessBackend) Dispense(name string) (interface{}, error)
Dispense returns the provider registered under the given name.
func (*InProcessBackend) Exited ¶ added in v0.1.4
func (b *InProcessBackend) Exited() bool
Exited returns true if the backend has been stopped.
func (*InProcessBackend) Healthy ¶ added in v0.1.4
func (b *InProcessBackend) Healthy() bool
Healthy returns true if the backend has not been stopped.
func (*InProcessBackend) Kill ¶ added in v0.1.4
func (b *InProcessBackend) Kill()
Kill is equivalent to Stop for in-process backends.
func (*InProcessBackend) NegotiatedVersion ¶ added in v0.2.0
func (b *InProcessBackend) NegotiatedVersion() int
NegotiatedVersion returns the current protocol version for in-process backends.
func (*InProcessBackend) Stop ¶ added in v0.1.4
func (b *InProcessBackend) Stop() error
Stop marks the backend as stopped.
type PluginBackend ¶ added in v0.1.4
type PluginBackend interface {
// Dispense returns a capability client by name (e.g. "resource", "exec").
Dispense(name string) (interface{}, error)
// Healthy returns true if the plugin is alive and serving.
Healthy() bool
// Stop performs a graceful shutdown of the plugin.
Stop() error
// Kill forcefully terminates the plugin.
Kill()
// Exited returns true if the plugin process has exited.
Exited() bool
// NegotiatedVersion returns the SDK protocol version negotiated with this plugin.
// For InProcessBackend, returns CurrentProtocolVersion.
// For ExternalBackend, returns the go-plugin negotiated version.
NegotiatedVersion() int
}
PluginBackend abstracts the communication channel to a plugin process. The primary implementation wraps go-plugin (ExternalBackend), but this interface also enables in-process backends for tests and future bundled plugins.
type PluginManager ¶
type PluginManager interface {
// OnPluginInit is called after the plugin is loaded in to do any pre-startup initialization.
OnPluginInit(ctx context.Context, pluginID string, meta config.PluginMeta) error
// OnPluginStart is called when the plugin is started.
OnPluginStart(ctx context.Context, pluginID string, meta config.PluginMeta) error
// OnPluginStop is called when the plugin is stopped. Modules should perform any persisting of state here
OnPluginStop(ctx context.Context, pluginID string, meta config.PluginMeta) error
// OnPluginShutdown is called when the plugin is shutdown. This is the last chance to clean up any resources
// before the IDE is closed.
OnPluginShutdown(ctx context.Context, pluginID string, meta config.PluginMeta) error
// OnPluginDestroy is called when the plugin is being removed from the system. This is the last chance to
// clean up any resources associated with the plugin before it is uninstalled.
OnPluginDestroy(ctx context.Context, pluginID string, meta config.PluginMeta) error
}
PluginManager must fulfil handling the event that happen during the plugin lifecycle.
type PluginManagerConfig ¶
type PluginManagerConfig struct {
// contains filtered or unexported fields
}
PluginManagerConfig is the configuration for the core plugin system.
func (*PluginManagerConfig) PluginsPath ¶
func (c *PluginManagerConfig) PluginsPath() string
PluginsPath returns the path on the filesystem to where plugins are stored.
type PluginRecord ¶ added in v0.1.4
type PluginRecord struct {
// Persisted fields.
ID string `json:"id"`
Phase lifecycle.PluginPhase `json:"phase"`
Metadata config.PluginMeta `json:"metadata"`
Enabled bool `json:"enabled"`
DevMode bool `json:"devMode"`
DevPath string `json:"devPath,omitempty"`
LastError string `json:"lastError,omitempty"`
ErrorCount int `json:"errorCount"`
InstalledAt time.Time `json:"installedAt"`
// Runtime-only fields (not persisted).
StateMachine *lifecycle.PluginStateMachine `json:"-"`
Backend PluginBackend `json:"-"`
Capabilities []sdktypes.Capability `json:"-"`
ProtocolVersion int `json:"-"`
}
PluginRecord is the host-side runtime state for a managed plugin. It holds both persisted configuration and runtime-only fields.
func NewPluginRecord ¶ added in v0.1.4
func NewPluginRecord(id string, meta config.PluginMeta, initialPhase lifecycle.PluginPhase) *PluginRecord
NewPluginRecord creates a new PluginRecord with a state machine.
func (*PluginRecord) ToInfo ¶ added in v0.1.4
func (r *PluginRecord) ToInfo() sdktypes.PluginInfo
ToInfo converts the host-side record to a frontend-safe PluginInfo.
func (*PluginRecord) ToStateRecord ¶ added in v0.1.4
func (r *PluginRecord) ToStateRecord() PluginStateRecord
ToStateRecord converts a PluginRecord to its persistable form.
type PluginStateRecord ¶ added in v0.1.4
type PluginStateRecord struct {
ID string `json:"id"`
Phase lifecycle.PluginPhase `json:"phase"`
Metadata config.PluginMeta `json:"metadata"`
Enabled bool `json:"enabled"`
DevMode bool `json:"devMode"`
DevPath string `json:"devPath,omitempty"`
LastError string `json:"lastError,omitempty"`
ErrorCount int `json:"errorCount"`
InstalledAt time.Time `json:"installedAt"`
}
PluginStateRecord is the subset of PluginRecord that gets persisted to disk.