loader

package
v0.6.5 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2026 License: Apache-2.0 Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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
	Path     string // Full path to .wasm file
	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. Use with lazy loading - plugins will be loaded on first use.

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, only discovers plugins without loading them. Returns the number of successfully loaded/discovered plugins and any errors encountered.

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.

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. When WASM files are created, modified, or removed, the corresponding plugin is reloaded.

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.

Jump to

Keyboard shortcuts

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