Documentation ¶
Index ¶
- Variables
- func InternalLogger() *vlog.Logger
- func UseInternalLogger(l *vlog.Logger)
- type HostFn
- type RuntimeBuilder
- type RuntimeInstance
- type WasmEnvironment
- type WasmInstance
- func (w *WasmInstance) Call(fn string, args ...interface{}) (interface{}, error)
- func (w *WasmInstance) Ctx() *scheduler.Ctx
- func (w *WasmInstance) Deallocate(pointer int32, length int)
- func (w *WasmInstance) ExecutionResult() ([]byte, error)
- func (w *WasmInstance) ReadMemory(pointer int32, size int32) []byte
- func (w *WasmInstance) SendExecutionResult(result []byte, runErr error)
- func (w *WasmInstance) WriteMemory(data []byte) (int32, error)
- func (w *WasmInstance) WriteMemoryAtLocation(pointer int32, data []byte)
Constants ¶
This section is empty.
Variables ¶
var ErrExportNotFound = errors.New("the requested export is not found in the module")
Functions ¶
func InternalLogger ¶
func UseInternalLogger ¶
UseInternalLogger sets the logger to be used log internal wasm runtime messages
Types ¶
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)