Documentation
¶
Overview ¶
Package plugin provides a focused plugin registry and supporting helpers.
Index ¶
- Variables
- type ExecSandbox
- type Factory
- type FactoryRegistry
- type Plugin
- type Registry
- func (r *Registry) DiscoverFromValues(values ...interface{}) int
- func (r *Registry) Get(name string) (Plugin, bool)
- func (r *Registry) Names() []string
- func (r *Registry) Register(p Plugin) error
- func (r *Registry) StartAll() []error
- func (r *Registry) StopAll() []error
- func (r *Registry) Unregister(name string)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrAlreadyRegistered indicates a plugin with the same name is already registered. ErrAlreadyRegistered = errors.New("plugin: already registered") // ErrFactoryExists indicates a factory for the given name already exists. ErrFactoryExists = errors.New("plugin: factory already exists") // ErrFactoryNotFound indicates no factory exists for the requested name. ErrFactoryNotFound = errors.New("plugin: factory not found") )
Functions ¶
This section is empty.
Types ¶
type ExecSandbox ¶
type ExecSandbox struct {
// contains filtered or unexported fields
}
ExecSandbox runs a plugin as an external process using a simple JSON-over-stdio protocol.
func NewExecSandbox ¶
func NewExecSandbox(path string, args ...string) *ExecSandbox
NewExecSandbox creates a sandbox around the provided binary path and arguments.
func (*ExecSandbox) Start ¶
func (e *ExecSandbox) Start(ctx context.Context) error
Start launches the external process and waits for a ready signal.
func (*ExecSandbox) Stop ¶
func (e *ExecSandbox) Stop() error
Stop sends a stop command and waits for the external process to exit.
type FactoryRegistry ¶
type FactoryRegistry struct {
// contains filtered or unexported fields
}
FactoryRegistry stores plugin factories by name.
func NewFactoryRegistry ¶
func NewFactoryRegistry() *FactoryRegistry
NewFactoryRegistry creates an empty factory registry.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry manages plugin registration and lifecycle in a deterministic order.
func (*Registry) DiscoverFromValues ¶
DiscoverFromValues inspects provided values and registers any that implement Plugin.
func (*Registry) StartAll ¶
StartAll starts plugins in insertion order and returns any collected errors.
func (*Registry) StopAll ¶
StopAll stops plugins in reverse insertion order and returns any collected errors.
func (*Registry) Unregister ¶
Unregister removes a plugin by name.