execution

package
v0.90.0 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

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 handles WASM module execution.

func NewExecutor

func NewExecutor(runtime wazero.Runtime, logger *zap.Logger) *Executor

NewExecutor creates a new Executor.

func (*Executor) CallHandleFunction

func (e *Executor) CallHandleFunction(ctx context.Context, instance api.Module, input []byte) ([]byte, error)

CallHandleFunction calls the main 'handle' export in the WASM module. This is an alternative execution path for modules that export a 'handle' function.

func (*Executor) ExecuteModule

func (e *Executor) ExecuteModule(ctx context.Context, compiled wazero.CompiledModule, moduleName string, input []byte, contextSetter func(), contextClearer func()) ([]byte, error)

ExecuteModule instantiates and runs a WASM module with the given input. The contextSetter callback is used to set invocation context on host services.

func (*Executor) ReadFromGuest

func (e *Executor) ReadFromGuest(mod api.Module, ptr, size uint32) ([]byte, bool)

ReadFromGuest reads a string from guest memory.

func (*Executor) UnmarshalJSONFromGuest

func (e *Executor) UnmarshalJSONFromGuest(mod api.Module, ptr, size uint32, v interface{}) error

UnmarshalJSONFromGuest reads and unmarshals JSON data from guest memory.

func (*Executor) WriteToGuest

func (e *Executor) WriteToGuest(ctx context.Context, mod api.Module, data []byte) uint64

WriteToGuest allocates memory in the guest WASM module and writes data to it. Returns a packed uint64 with ptr in upper 32 bits and length in lower 32 bits.

type ModuleInfo

type ModuleInfo struct {
	CID       string
	SizeBytes int
	Compiled  bool
}

ModuleInfo provides information about a compiled module.

type ModuleLifecycle

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

ModuleLifecycle manages the lifecycle of WASM modules.

func NewModuleLifecycle

func NewModuleLifecycle(runtime wazero.Runtime, logger *zap.Logger) *ModuleLifecycle

NewModuleLifecycle creates a new ModuleLifecycle manager.

func (*ModuleLifecycle) CloseModule

func (m *ModuleLifecycle) CloseModule(ctx context.Context, module wazero.CompiledModule, wasmCID string) error

CloseModule closes a compiled module and releases its resources.

func (*ModuleLifecycle) CloseModules

func (m *ModuleLifecycle) CloseModules(ctx context.Context, modules map[string]wazero.CompiledModule) []error

CloseModules closes multiple compiled modules.

func (*ModuleLifecycle) CompileModule

func (m *ModuleLifecycle) CompileModule(ctx context.Context, wasmCID string, wasmBytes []byte) (wazero.CompiledModule, error)

CompileModule compiles WASM bytecode into a compiled module.

func (*ModuleLifecycle) GetModuleInfo

func (m *ModuleLifecycle) GetModuleInfo(wasmCID string, wasmBytes []byte, isCompiled bool) *ModuleInfo

GetModuleInfo returns information about a module.

func (*ModuleLifecycle) InstantiateModule

func (m *ModuleLifecycle) InstantiateModule(ctx context.Context, compiled wazero.CompiledModule, config wazero.ModuleConfig) error

InstantiateModule creates a module instance for execution. Note: This method is currently unused but kept for potential future use.

func (*ModuleLifecycle) ValidateModule

func (m *ModuleLifecycle) ValidateModule(module wazero.CompiledModule) error

ValidateModule performs basic validation on compiled module.

Jump to

Keyboard shortcuts

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