runtime

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrExportNotFound = errors.New("the requested export is not found in the module")

Functions

func InternalLogger

func InternalLogger() *vlog.Logger

func UseInternalLogger

func UseInternalLogger(l *vlog.Logger)

UseInternalLogger sets the logger to be used log internal wasm runtime messages

Types

type HostFn

type HostFn struct {
	Name     string
	ArgCount int
	Returns  bool
	HostFn   innerFunc
}

HostFn describes a host function callable from within a Runnable module

func NewHostFn

func NewHostFn(name string, argCount int, returns bool, fn innerFunc) HostFn

NewHostFn creates a new host function

type RuntimeBuilder

type RuntimeBuilder interface {
	New() (RuntimeInstance, error)
}

RuntimeBuilder is a factory-style interface that can build Wasm runtimes

type RuntimeInstance

type RuntimeInstance interface {
	Call(fn string, args ...interface{}) (interface{}, error)
	ReadMemory(pointer int32, size int32) []byte
	WriteMemory(data []byte) (int32, error)
	WriteMemoryAtLocation(pointer int32, data []byte)
	Deallocate(pointer int32, length int)
	Close()
}

RuntimeInstance is an interface that wraps various underlying Wasm runtimes like Wasmer, Wasmtime

type WasmEnvironment

type WasmEnvironment struct {
	UUID string
	// contains filtered or unexported fields
}

WasmEnvironment is an environment in which Wasm instances run

func NewEnvironment

func NewEnvironment(builder RuntimeBuilder) *WasmEnvironment

NewEnvironment creates a new environment with a pool of available wasmInstances

func (*WasmEnvironment) AddInstance

func (w *WasmEnvironment) AddInstance() error

AddInstance adds a new Wasm instance to the environment's pool

func (*WasmEnvironment) RemoveInstance

func (w *WasmEnvironment) RemoveInstance() error

RemoveInstance removes one of the active instances from rotation and destroys it

func (*WasmEnvironment) UseInstance

func (w *WasmEnvironment) UseInstance(ctx *scheduler.Ctx, instFunc func(*WasmInstance, int32)) error

UseInstance provides an instance from the environment's pool to be used by a callback function

type WasmInstance

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

WasmInstance is an instance of a Wasm runtime

func InstanceForIdentifier

func InstanceForIdentifier(ident int32, needsFFIResult bool) (*WasmInstance, error)

func (*WasmInstance) Call

func (w *WasmInstance) Call(fn string, args ...interface{}) (interface{}, error)

Call executes a function from the Wasm Module

func (*WasmInstance) Ctx

func (w *WasmInstance) Ctx() *scheduler.Ctx

Ctx returns the instance's Ctx

func (*WasmInstance) Deallocate

func (w *WasmInstance) Deallocate(pointer int32, length int)

func (*WasmInstance) ExecutionResult

func (w *WasmInstance) ExecutionResult() ([]byte, error)

ExecutionResult gets the runnable's execution results

func (*WasmInstance) ReadMemory

func (w *WasmInstance) ReadMemory(pointer int32, size int32) []byte

func (*WasmInstance) SendExecutionResult

func (w *WasmInstance) SendExecutionResult(result []byte, runErr error)

SendExecutionResult allows FFI functions to send the run result

func (*WasmInstance) WriteMemory

func (w *WasmInstance) WriteMemory(data []byte) (int32, error)

func (*WasmInstance) WriteMemoryAtLocation

func (w *WasmInstance) WriteMemoryAtLocation(pointer int32, data []byte)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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