wasm

package
v0.6.4 Latest Latest
Warning

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

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

Documentation

Overview

Package wasm provides a WASM-based plugin runtime using wazero.

WASM plugins are portable, sandboxed modules that communicate with the host via exported functions. This is the default/recommended plugin runtime.

Plugin contract:

  • Export gk_register() -> returns JSON manifest
  • Export gk_call(fn_ptr, fn_len, args_ptr, args_len) -> returns response ptr
  • Export gk_malloc(size) -> allocate memory for host-to-plugin data
  • Export gk_free(ptr) -> free memory

Host provides:

  • gk_host_call(fn_ptr, fn_len, args_ptr, args_len) -> call host API
  • gk_log(level, msg_ptr, msg_len) -> logging

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type WASMPlugin

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

WASMPlugin implements plugin.Plugin for WASM modules.

func Load

func Load(ctx context.Context, wasmBytes []byte) (*WASMPlugin, error)

Load creates a WASM plugin from raw bytes.

func LoadFromFile

func LoadFromFile(ctx context.Context, path string) (*WASMPlugin, error)

LoadFromFile loads a WASM plugin from a file path.

func (*WASMPlugin) Call

func (p *WASMPlugin) Call(ctx context.Context, fn string, args json.RawMessage) (json.RawMessage, error)

Call implements plugin.Plugin.

func (*WASMPlugin) GKRegister

func (p *WASMPlugin) GKRegister() plugin.GKRegistration

GKRegistration implements plugin.Plugin.

func (*WASMPlugin) Init

func (p *WASMPlugin) Init(ctx context.Context, host plugin.HostAPI) error

Init implements plugin.Plugin.

func (*WASMPlugin) Shutdown

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

Shutdown implements plugin.Plugin.

Jump to

Keyboard shortcuts

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