Help us shape the future of Go! Take the 2026 Go Developer Survey

wasm

package
v0.12.0 Latest Latest
Warning

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

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

Documentation

Overview

Package wasm implements the WASM/WASI container runner. Supports WasmEdge, WAMR, and Wasmtime backends.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend interface {
	// Name returns the backend name.
	Name() string
	// Detect checks if the backend binary is available.
	Detect() bool
	// Run starts a WASM module with the given configuration.
	Run(ctx context.Context, wasmPath string, cfg *WASMConfig) (int, error)
	// Stop terminates a process by PID.
	Stop(pid int) error
}

Backend represents a WASM runtime backend.

type Runner

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

Runner executes WASM containers using available backends.

func New

func New(root string) *Runner

New creates a new WASM runner with detected backends.

func (*Runner) Capabilities

func (r *Runner) Capabilities() rt.RunnerCapabilities

Capabilities returns the runner's supported features and architectures.

func (*Runner) Cleanup

func (r *Runner) Cleanup(_ context.Context, id string) error

Cleanup removes the container directory.

func (*Runner) Create

func (r *Runner) Create(_ context.Context, cfg *rt.Config) (string, error)

Create initializes a new WASM container directory.

func (*Runner) Detect

func (r *Runner) Detect() bool

Detect reports whether a WASM backend is available.

func (*Runner) Exec

func (r *Runner) Exec(_ context.Context, _ string, _ *rt.ExecConfig) (int, error)

Exec is not supported in WASM mode.

func (*Runner) Inspect

func (r *Runner) Inspect(_ context.Context, id string) (*rt.ContainerJSON, error)

Inspect returns container metadata and state.

func (*Runner) Kill

func (r *Runner) Kill(_ context.Context, id string, _ syscall.Signal) error

Kill sends a signal to stop the WASM container process.

func (*Runner) Name

func (r *Runner) Name() rt.ExecutionMode

Name returns the execution mode for this runner.

func (*Runner) Pause

func (r *Runner) Pause(_ context.Context, _ string) error

Pause is not supported in WASM mode.

func (*Runner) Resume

func (r *Runner) Resume(_ context.Context, _ string) error

Resume is not supported in WASM mode.

func (*Runner) Start

func (r *Runner) Start(ctx context.Context, id string) (int, error)

Start begins execution of a WASM container.

func (*Runner) Stats

func (r *Runner) Stats(_ context.Context, _ string) (*rt.ContainerStats, error)

Stats returns empty container statistics.

func (*Runner) Stop

func (r *Runner) Stop(_ context.Context, id string, _ time.Duration) error

Stop terminates a WASM container by its process ID.

func (*Runner) Wait

func (r *Runner) Wait(_ context.Context, _ string) (int, error)

Wait is a no-op in WASM mode.

type WAMRBackend

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

WAMRBackend is a WASM backend using the WAMR (iwasm) runtime.

func (*WAMRBackend) Detect

func (b *WAMRBackend) Detect() bool

Detect checks for the iwasm binary.

func (*WAMRBackend) Name

func (b *WAMRBackend) Name() string

Name returns "wamr".

func (*WAMRBackend) Run

func (b *WAMRBackend) Run(ctx context.Context, wasmPath string, cfg *WASMConfig) (int, error)

Run executes a WASM module with WAMR.

func (*WAMRBackend) Stop

func (b *WAMRBackend) Stop(pid int) error

Stop kills a process by PID.

type WASMConfig

type WASMConfig struct {
	Rootfs string
	Args   []string
	Env    []string
	Cwd    string
}

WASMConfig holds configuration for a WASM container.

type WasmEdgeBackend

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

WasmEdgeBackend is a WASM backend using the WasmEdge runtime.

func (*WasmEdgeBackend) Detect

func (b *WasmEdgeBackend) Detect() bool

Detect checks for the wasmedge binary.

func (*WasmEdgeBackend) Name

func (b *WasmEdgeBackend) Name() string

Name returns "wasmedge".

func (*WasmEdgeBackend) Run

func (b *WasmEdgeBackend) Run(ctx context.Context, wasmPath string, cfg *WASMConfig) (int, error)

Run executes a WASM module with WasmEdge.

func (*WasmEdgeBackend) Stop

func (b *WasmEdgeBackend) Stop(pid int) error

Stop kills a process by PID.

type WasmtimeBackend

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

WasmtimeBackend is a WASM backend using the Wasmtime runtime.

func (*WasmtimeBackend) Detect

func (b *WasmtimeBackend) Detect() bool

Detect checks for the wasmtime binary.

func (*WasmtimeBackend) Name

func (b *WasmtimeBackend) Name() string

Name returns "wasmtime".

func (*WasmtimeBackend) Run

func (b *WasmtimeBackend) Run(ctx context.Context, wasmPath string, cfg *WASMConfig) (int, error)

Run executes a WASM module with Wasmtime.

func (*WasmtimeBackend) Stop

func (b *WasmtimeBackend) Stop(pid int) error

Stop kills a process by PID.

Jump to

Keyboard shortcuts

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