plugin

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2025 License: MIT Imports: 38 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrConflict = errors.New("plugin conflict occurred")
	ErrNotFound = errors.New("plugin not found")
)
View Source
var ErrInvalidSignature = errors.New("invalid signature")
View Source
var ErrMissingDependency = errors.New("missing dependency")
View Source
var MapTypes = map[reflect.Value][]reflect.Type{}

MapTypes maps functions to types they handle specially.

View Source
var Symbols = map[string]map[string]reflect.Value{}

Symbols maps package paths to their exported symbols.

Functions

This section is empty.

Types

type LoadOptions

type LoadOptions struct {
	GoPath string
	Config any
}

LoadOptions specifies options for loading a plugin.

type Loader

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

Loader loads plugins from Go source or compiled shared object files.

func NewLoader

func NewLoader(fs afero.Fs) *Loader

NewLoader returns a new Loader using the given filesystem.

func (*Loader) Open

func (l *Loader) Open(path string, options ...LoadOptions) (Plugin, error)

Open loads and initializes a plugin with the given config.

type Plugin

type Plugin interface {
	Name() string
	Version() string
	Load(ctx context.Context) error
	Unload(ctx context.Context) error
}

Plugin defines the interface that dynamic plugins must implement.

type Registry

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

Registry manages a list of plugins and controls their lifecycle.

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new plugin registry.

func (*Registry) Inject

func (r *Registry) Inject(dependency any) (int, error)

Inject attempts to inject the given dependency into all registered plugins.

func (*Registry) Load

func (r *Registry) Load(ctx context.Context) error

Load calls Load on all registered plugins.

func (*Registry) Plugins

func (r *Registry) Plugins() []Plugin

Plugins returns a slice of all registered plugins.

func (*Registry) Register

func (r *Registry) Register(plugin Plugin) error

Register adds a plugin to the registry.

func (*Registry) Unload

func (r *Registry) Unload(ctx context.Context) error

Unload calls Unload on all registered plugins in reverse order.

func (*Registry) Unregister

func (r *Registry) Unregister(plugin Plugin) error

Unregister removes a plugin from the registry.

Jump to

Keyboard shortcuts

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