Documentation
¶
Overview ¶
Package engine runs pack WASM modules in wazero: a module compiled once, a bounded pool of pre-warmed instances, and calls with a deadline that pass JSON through linear memory (the ABI in core/src/abi.rs).
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrPoolBusy = errors.New("engine: every instance is busy")
ErrPoolBusy is returned when no instance frees up before the deadline.
Functions ¶
Types ¶
type CallError ¶
type CallError struct {
Capability string
Message string
// Code names the kind of failure when the capability gave one
// (abi::Error::code in Rust), such as "unsupported_format"; empty
// otherwise.
Code string
}
CallError is an error the capability itself returned.
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
Module is a compiled WASM module.
func Compile ¶
Compile compiles wasm with WASI available to it and no filesystem, clock or network beyond what WASI preview 1 exposes.
type Options ¶
type Options struct {
// MemoryMB caps each instance's linear memory; default 64.
MemoryMB int
// Uninterruptible drops the deadline checks the compiler otherwise
// inserts at every loop back-edge. Loops run several times faster; a
// call that overruns the pool deadline then returns an error to its
// caller but keeps running inside its instance until it finishes, and
// that instance is discarded afterwards. For capabilities whose loops
// are bounded by their input.
Uninterruptible bool
}
Options bounds a module.
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool is a bounded set of pre-warmed instances. A call takes one, runs with the pool's deadline, and returns it; an instance whose call was cut off by the deadline is discarded and replaced.
func (*Pool) Call ¶
Call runs the capability fn with a JSON input and returns its JSON output. It waits for an instance no longer than the pool timeout.