loader

package
v0.0.0-...-e948ea5 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidatePluginPath

func ValidatePluginPath(path string) error

ValidatePluginPath validates that a plugin path is safe to load

Types

type LoadedPlugin

type LoadedPlugin struct {
	Path      string
	Plugin    plugin.ServicePlugin
	LibHandle uintptr
	RefCount  int
	// contains filtered or unexported fields
}

LoadedPlugin tracks a loaded external plugin

type LoadedWASMPlugin

type LoadedWASMPlugin struct {
	Path     string
	Plugin   plugin.ServicePlugin
	Runtime  wazero.Runtime
	Module   wazeroapi.Module
	RefCount int
	// contains filtered or unexported fields
}

LoadedWASMPlugin tracks a loaded WASM plugin

type PluginInfo

type PluginInfo struct {
	Path     string
	Name     string
	Type     PluginType
	IsLoaded bool
}

PluginInfo contains metadata about a discovered plugin

func DiscoverPlugins

func DiscoverPlugins(dir string) ([]PluginInfo, error)

DiscoverPlugins searches for plugin files in a directory (both native and WASM)

type PluginLoader

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

PluginLoader manages loading and unloading of external plugins

func NewPluginLoader

func NewPluginLoader() *PluginLoader

NewPluginLoader creates a new plugin loader

func (*PluginLoader) GetLoadedPlugins

func (pl *PluginLoader) GetLoadedPlugins() []string

GetLoadedPlugins returns a list of all loaded plugins (both native and WASM)

func (*PluginLoader) IsLoaded

func (pl *PluginLoader) IsLoaded(libraryPath string) bool

IsLoaded checks if a plugin is currently loaded (both native and WASM) The plugin type is automatically detected based on file magic number and extension

func (*PluginLoader) IsLoadedWithType

func (pl *PluginLoader) IsLoadedWithType(libraryPath string, pluginType PluginType) bool

IsLoadedWithType checks if a plugin of a specific type is currently loaded

func (*PluginLoader) LoadPlugin

func (pl *PluginLoader) LoadPlugin(libraryPath string) (plugin.ServicePlugin, error)

LoadPlugin loads a plugin from a shared library file (.so, .dylib, .dll) or WASM file (.wasm) The plugin type is automatically detected based on file magic number and extension

func (*PluginLoader) LoadPluginWithType

func (pl *PluginLoader) LoadPluginWithType(libraryPath string, pluginType PluginType, hostFS ...interface{}) (plugin.ServicePlugin, error)

LoadPluginWithType loads a plugin with an explicitly specified type For WASM plugins, optional hostFS can be provided to allow access to host filesystem

func (*PluginLoader) LoadPluginsFromDirectory

func (pl *PluginLoader) LoadPluginsFromDirectory(dir string) ([]string, []error)

LoadPluginsFromDirectory loads all plugins from a directory

func (*PluginLoader) UnloadPlugin

func (pl *PluginLoader) UnloadPlugin(libraryPath string) error

UnloadPlugin unloads a plugin (decrements ref count, unloads when reaches 0) The plugin type is automatically detected based on file magic number and extension

func (*PluginLoader) UnloadPluginWithType

func (pl *PluginLoader) UnloadPluginWithType(libraryPath string, pluginType PluginType) error

UnloadPluginWithType unloads a plugin with an explicitly specified type

type PluginType

type PluginType int

PluginType represents the type of plugin

const (
	// PluginTypeUnknown represents an unknown plugin type
	PluginTypeUnknown PluginType = iota
	// PluginTypeNative represents a native shared library plugin (.so, .dylib, .dll)
	PluginTypeNative
	// PluginTypeWASM represents a WebAssembly plugin (.wasm)
	PluginTypeWASM
)

func DetectPluginType

func DetectPluginType(libraryPath string) (PluginType, error)

DetectPluginType detects the type of plugin based on file content and extension

func (PluginType) String

func (pt PluginType) String() string

String returns the string representation of the plugin type

type WASMPluginLoader

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

WASMPluginLoader manages loading and unloading of WASM plugins

func NewWASMPluginLoader

func NewWASMPluginLoader() *WASMPluginLoader

NewWASMPluginLoader creates a new WASM plugin loader

func (*WASMPluginLoader) GetLoadedPlugins

func (wl *WASMPluginLoader) GetLoadedPlugins() []string

GetLoadedPlugins returns a list of all loaded WASM plugins

func (*WASMPluginLoader) IsLoaded

func (wl *WASMPluginLoader) IsLoaded(wasmPath string) bool

IsLoaded checks if a WASM plugin is currently loaded

func (*WASMPluginLoader) LoadWASMPlugin

func (wl *WASMPluginLoader) LoadWASMPlugin(wasmPath string, hostFS ...interface{}) (plugin.ServicePlugin, error)

LoadWASMPlugin loads a plugin from a WASM file If hostFS is provided, it will be exposed to the WASM plugin as host functions

func (*WASMPluginLoader) UnloadWASMPlugin

func (wl *WASMPluginLoader) UnloadWASMPlugin(wasmPath string) error

UnloadWASMPlugin unloads a WASM plugin (decrements ref count, unloads when reaches 0)

Jump to

Keyboard shortcuts

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