host

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Capability

type Capability = ext.Capability

Capability is an alias of ext.Capability — the public extension type is canonical; this alias lets internal callers keep the short name without importing the ext path everywhere.

type Plugin

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

Plugin is a single loaded WASM module with the three required Pulp exports.

func Load

func Load(ctx context.Context, spec *manifest.PluginSpec, registry *Registry, logger *slog.Logger) (*Plugin, error)

Load reads the plugin's WASM file, binds the host capabilities declared in its manifest, instantiates the module, and resolves the three required exports. Host capabilities are bound via the Registry before the plugin module is instantiated so its imports resolve correctly.

Passing a nil registry is valid — the plugin gets only the WASI imports wazero provides by default and no Pulp host imports. Useful for tests.

func (*Plugin) Close

func (p *Plugin) Close(ctx context.Context) error

Close tears down the wazero runtime and releases all plugin resources.

func (*Plugin) Init

func (p *Plugin) Init(ctx context.Context, config []byte) error

Init calls pulp_init with the given config bytes. Config is written into WASM linear memory; the plugin receives (ptr, len).

func (*Plugin) Name

func (p *Plugin) Name() string

Name returns the plugin's manifest name. Defined to satisfy the ext.Plugin interface extensions receive when their Register or Stub functions run.

func (*Plugin) ProbeConfigMarker

func (p *Plugin) ProbeConfigMarker(ctx context.Context) (int64, bool)

ProbeConfigMarker reads the plugin's probe_config_marker export if present. Diagnostic only — used by the integration test to verify the manifest [config] table round-tripped through MessagePack into the plugin.

func (*Plugin) ProbeLastCall

func (p *Plugin) ProbeLastCall(ctx context.Context) (uint64, bool)

ProbeLastCall reads the plugin's probe_last_call export if present. Diagnostic only — returns ok=false if the plugin does not expose it.

func (*Plugin) Shutdown

func (p *Plugin) Shutdown(ctx context.Context) error

Shutdown calls pulp_shutdown. Error if the plugin returns nonzero or traps.

func (*Plugin) Step

func (p *Plugin) Step(ctx context.Context, env abi.StepEnvelope) (outputHandle int32, err error)

Step encodes the envelope, writes it into WASM linear memory, and calls pulp_step. Returns the output handle (0 means no output).

type Registry

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

A Registry collects the Capabilities that this Pulp host knows how to provide. Some capabilities are always bound regardless of the manifest (logging, entropy); others are only bound when declared explicitly (transport.http.inbound, storage.sqlite, spawn.docker).

The registry is created at host startup and reused across plugin loads.

func NewRegistry

func NewRegistry() *Registry

NewRegistry returns a Registry prepopulated with every extension that registered via ext.Register. Callers add built-in capabilities on top via Always / Gated before passing it to Load.

func (*Registry) Always

func (r *Registry) Always(c Capability)

Always marks the capability as bound for every plugin, no declaration required. Use for universal imports like logging.

func (*Registry) Gated

func (r *Registry) Gated(c Capability)

Gated marks the capability as bound only when the plugin's manifest lists it under `capabilities`. Use for anything that touches the OS or the network.

Jump to

Keyboard shortcuts

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