host

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package host provides the runtime environment for executing Reglet WASM plugins.

It abstracts the underlying WASM engine (wazero), manages plugin lifecycle, and handles the low-level ABI interactions (memory allocation, data packing/unpacking). This package also facilitates the registration of host functions, enabling plugins to securely access system capabilities exposed by the host.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Executor

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

Executor manages the lifecycle of a WASM plugin.

func NewExecutor

func NewExecutor(ctx context.Context, opts ...Option) (*Executor, error)

NewExecutor creates a new executor with the given options.

func (*Executor) Close

func (e *Executor) Close(ctx context.Context) error

Close releases resources held by the executor.

func (*Executor) LoadPlugin

func (e *Executor) LoadPlugin(ctx context.Context, wasmBytes []byte) (*PluginInstance, error)

LoadPlugin instantiates a WASM module.

type Loader

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

Loader orchestrates the manifest loading pipeline.

func NewLoader

func NewLoader(opts ...LoaderOption) *Loader

NewLoader creates a new Loader with defaults.

func (*Loader) LoadManifest

func (l *Loader) LoadManifest(raw []byte, config map[string]interface{}) (*entities.PluginManifest, error)

LoadManifest loads, parses, and validates a plugin manifest.

type LoaderOption

type LoaderOption func(*loaderConfig)

LoaderOption configures the Loader.

func WithParser

func WithParser(p ports.ManifestParser) LoaderOption

WithParser sets a custom manifest parser.

func WithRegistry

func WithRegistry(r ports.CapabilityRegistry) LoaderOption

WithRegistry configures the loader with a capability registry for validation.

func WithStrictTemplates

func WithStrictTemplates(enabled bool) LoaderOption

WithStrictTemplates enables/disables strict template mode. When enabled (default), template rendering fails if a referenced key is missing. Disable only for development or when missing keys should become empty strings.

func WithTemplateEngine

func WithTemplateEngine(t ports.TemplateEngine) LoaderOption

WithTemplateEngine sets a template engine.

type Option

type Option func(*Executor)

Option defines a functional option for configuring the Executor.

func WithHostFunctions

func WithHostFunctions(registry *hostfuncs.HandlerRegistry) Option

WithHostFunctions configures the executor with a host function registry.

type PluginInstance

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

PluginInstance represents an instantiated WASM plugin.

func (*PluginInstance) Check

func (p *PluginInstance) Check(ctx context.Context, config map[string]any) (entities.Result, error)

Check calls the "observe" export of the plugin.

func (*PluginInstance) Describe

func (p *PluginInstance) Describe(ctx context.Context) (entities.Metadata, error)

Describe calls the "describe" export of the plugin.

func (*PluginInstance) Schema

func (p *PluginInstance) Schema(ctx context.Context) ([]byte, error)

Schema calls the "schema" export of the plugin.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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