loader

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DiscoveredPlugin

type DiscoveredPlugin struct {
	Name     string // Derived from filename or manifest
	Path     string // Full path to .wasm file or plugin directory
	Type     string // "wasm" or "grpc"
	Loaded   bool   // Whether it's been loaded
	LoadedAt time.Time
}

DiscoveredPlugin holds info about a plugin found but not yet loaded.

type Loader

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

Loader handles discovery and loading of plugins from the filesystem.

func NewLoader

func NewLoader(pluginDir string, manager *plugin.Manager, logger *slog.Logger, opts ...LoaderOption) *Loader

NewLoader creates a plugin loader for the given directory.

func (*Loader) DiscoverAll

func (l *Loader) DiscoverAll() (int, error)

DiscoverAll scans the plugin directory and records available plugins without loading them. Discovers both .wasm files and gRPC plugins (directories with plugin.yaml).

func (*Loader) Discovered

func (l *Loader) Discovered() []string

Discovered returns the names of discovered (but possibly not loaded) plugins. Implements plugin.LazyLoader interface.

func (*Loader) DiscoveredPlugins

func (l *Loader) DiscoveredPlugins() []*DiscoveredPlugin

DiscoveredPlugins returns detailed info about discovered plugins.

func (*Loader) EnsureLoaded

func (l *Loader) EnsureLoaded(ctx context.Context, name string) error

EnsureLoaded loads a plugin by name if not already loaded (for lazy loading).

func (*Loader) LoadAll

func (l *Loader) LoadAll(ctx context.Context) (int, []error)

LoadAll discovers and loads all plugins from the plugin directory. If lazy loading is enabled, WASM plugins are only discovered (loaded on first call). gRPC plugins are always eagerly loaded because they register routes that must exist before the HTTP server starts accepting requests. Returns the number of successfully loaded/discovered plugins and any errors encountered.

func (*Loader) LoadOrReload added in v0.7.0

func (l *Loader) LoadOrReload(ctx context.Context, name string) error

LoadOrReload re-discovers plugins and then loads or reloads the named plugin. Use after uploading a new plugin to ensure it's picked up even if it wasn't present at startup.

func (*Loader) LoadWASM

func (l *Loader) LoadWASM(ctx context.Context, name string) error

LoadWASM loads a single WASM plugin by name (without .wasm extension).

func (*Loader) LoadWASMFromPath

func (l *Loader) LoadWASMFromPath(ctx context.Context, path string) error

LoadWASMFromPath loads a WASM plugin from an arbitrary path.

func (*Loader) Reload

func (l *Loader) Reload(ctx context.Context, name string) error

Reload unloads and reloads a plugin by name using atomic replacement to avoid race conditions.

func (*Loader) StopWatch

func (l *Loader) StopWatch()

StopWatch stops the file watcher.

func (*Loader) Unload

func (l *Loader) Unload(ctx context.Context, name string) error

Unload unloads a plugin by name.

func (*Loader) WatchDir

func (l *Loader) WatchDir(ctx context.Context) error

WatchDir sets up a file watcher for hot reload. Watches for .wasm file changes and gRPC binary changes (via plugin.yaml).

type LoaderOption

type LoaderOption func(*Loader)

LoaderOption configures a Loader.

func WithLazyLoading

func WithLazyLoading() LoaderOption

WithLazyLoading enables lazy loading - plugins are discovered but not loaded until first use.

func WithSignatureVerification added in v0.7.0

func WithSignatureVerification(trustedKeys []ed25519.PublicKey) LoaderOption

WithSignatureVerification enables plugin binary signature verification. Only plugins signed with one of the trusted keys will be allowed to load.

type PluginManifest added in v0.7.0

type PluginManifest = pkgplugin.PluginManifest

PluginManifest is an alias for the shared manifest type.

Jump to

Keyboard shortcuts

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