Documentation
¶
Index ¶
- type Executor
- func (e *Executor) CallHandleFunction(ctx context.Context, instance api.Module, input []byte) ([]byte, error)
- func (e *Executor) ExecuteModule(ctx context.Context, compiled wazero.CompiledModule, moduleName string, ...) ([]byte, error)
- func (e *Executor) ReadFromGuest(mod api.Module, ptr, size uint32) ([]byte, bool)
- func (e *Executor) UnmarshalJSONFromGuest(mod api.Module, ptr, size uint32, v interface{}) error
- func (e *Executor) WriteToGuest(ctx context.Context, mod api.Module, data []byte) uint64
- type ModuleInfo
- type ModuleLifecycle
- func (m *ModuleLifecycle) CloseModule(ctx context.Context, module wazero.CompiledModule, wasmCID string) error
- func (m *ModuleLifecycle) CloseModules(ctx context.Context, modules map[string]wazero.CompiledModule) []error
- func (m *ModuleLifecycle) CompileModule(ctx context.Context, wasmCID string, wasmBytes []byte) (wazero.CompiledModule, error)
- func (m *ModuleLifecycle) GetModuleInfo(wasmCID string, wasmBytes []byte, isCompiled bool) *ModuleInfo
- func (m *ModuleLifecycle) InstantiateModule(ctx context.Context, compiled wazero.CompiledModule, ...) error
- func (m *ModuleLifecycle) ValidateModule(module wazero.CompiledModule) error
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 ¶
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 ¶
ReadFromGuest reads a string from guest memory.
func (*Executor) UnmarshalJSONFromGuest ¶
UnmarshalJSONFromGuest reads and unmarshals JSON data from guest memory.
type ModuleInfo ¶
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.