Documentation
¶
Overview ¶
Package runtime implements the src/ctx/web WebAssembly host contract with wazero. It does not assign an Ext plugin protocol to guest byte streams.
Index ¶
- Constants
- Variables
- func RunCommand(ctx context.Context, module []byte, opts CommandOptions) (int, error)
- type Command
- type CommandOptions
- type CompilationCache
- type Engine
- func (Engine) Inspect(ctx context.Context, module []byte) (Inspection, error)
- func (Engine) NewCompilationCache() contract.CompilationCache
- func (Engine) Open(ctx context.Context, module []byte, options Options) (contract.Command, error)
- func (Engine) OpenReactor(ctx context.Context, module []byte, abi ReactorABI, options ReactorOptions) (contract.Reactor, error)
- func (Engine) RunCommand(ctx context.Context, module []byte, options CommandOptions) (int, error)
- type Inspection
- type Options
- type Reactor
- type ReactorABI
- type ReactorOptions
- type StubImport
- type Target
Constants ¶
const ( TargetNone = contract.TargetNone TargetWASI = contract.TargetWASI TargetHost = contract.TargetHost TargetComponent = contract.TargetComponent )
const DefaultMemoryPages = contract.DefaultMemoryPages
const MaxModuleBytes = contract.MaxModuleBytes
Variables ¶
var ( ErrInvalid = contract.ErrInvalid ErrUnsupported = contract.ErrUnsupported ErrMismatch = contract.ErrMismatch ErrClosed = contract.ErrClosed )
Functions ¶
func RunCommand ¶
RunCommand compiles module and runs its _start function to completion. The result is the module's exit status; a non-zero status is not an error. Cancelling ctx terminates the module, including a compute loop that does no I/O, and returns the context's error.
Types ¶
type Command ¶
type Command struct {
// contains filtered or unexported fields
}
Command is one persistent WASI command. Read and Write exchange raw bytes with the command's stdout and stdin; this package assigns them no protocol.
func Open ¶
Open compiles module and starts one persistent WASI Preview 1 command. The returned stream is protocol-neutral. ctx bounds compilation, not the running command; Close terminates it.
type CommandOptions ¶
type CommandOptions = contract.CommandOptions
type CompilationCache ¶
type CompilationCache struct {
// contains filtered or unexported fields
}
CompilationCache keeps the compiled form of the modules opened with it, so opening the same module again skips compilation, which is most of the cost of Open for a large module. A nil cache in Options, ReactorOptions or CommandOptions compiles every time.
Share one among the sessions of a process, and Close it after they have closed. It is safe for concurrent use. It holds every module it compiles until it is closed, so it is not a budget on the number of distinct modules: a host that loads many unrelated modules decides for itself which sessions share one.
func NewCompilationCache ¶
func NewCompilationCache() *CompilationCache
NewCompilationCache returns an empty cache that lives in memory.
type Engine ¶
type Engine struct{}
Engine is a wazero implementation of the runtime-neutral web contract.
func (Engine) NewCompilationCache ¶
func (Engine) NewCompilationCache() contract.CompilationCache
func (Engine) OpenReactor ¶
func (Engine) OpenReactor(ctx context.Context, module []byte, abi ReactorABI, options ReactorOptions) (contract.Reactor, error)
func (Engine) RunCommand ¶
type Inspection ¶
type Inspection = contract.Inspection
type Reactor ¶
type Reactor struct {
// contains filtered or unexported fields
}
Reactor hosts one request/response WebAssembly reactor. Calls are serialized because a module instance is single-threaded.
func OpenReactor ¶
func OpenReactor(ctx context.Context, module []byte, abi ReactorABI, opts ReactorOptions) (*Reactor, error)
OpenReactor compiles module, validates the configured ABI exports, and opens one reactor handle. ctx bounds compilation and startup, not the instance.
func (*Reactor) Call ¶
func (r *Reactor) Call(ctx context.Context, operation uint32, request []byte) (uint32, []byte, error)
Call invokes one application-defined operation and returns its raw status and response bytes. The caller owns all protocol encoding and status semantics.
type ReactorABI ¶
type ReactorABI = contract.ReactorABI
type ReactorOptions ¶
type ReactorOptions = contract.ReactorOptions
type StubImport ¶
type StubImport = contract.StubImport