Documentation
¶
Overview ¶
Package component runs WebAssembly components (the Component Model, WASI Preview 2) on the same wazero engine that runs WASI Preview 1 modules.
wazero runs core modules only. A component is a set of core modules plus instructions for wiring them together and to the interfaces it imports. This package reads those instructions, instantiates each core module in wazero in the order the component gives, and supplies every imported interface itself. Nothing reaches the host except through the functions in wasi.go: the guest gets standard input and output (the broker's protocol), standard error, its arguments, clocks and random bytes. It gets no preopened directory, no environment variables and no network: socket creation and name lookup are refused, and an import of any interface outside the WASI 0.2 packages listed in allowedPackages is refused when the component is loaded.
Only the synchronous canonical ABI with UTF-8 strings is supported. A component that uses async, threads, its own resource types or a component import other than a WASI interface is refused with a message that says so.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Args []string
Stdin io.Reader
Stdout io.Writer
Stderr io.Writer
Walltime func() (sec int64, nsec int32)
Nanotime func() int64
Rand io.Reader
}
Config is what a component may see of the host. It mirrors what a WASI Preview 1 guest is given: arguments, the three standard streams, clocks and random bytes. There is deliberately no field for directories, environment variables or network access.
type Program ¶
type Program struct {
// contains filtered or unexported fields
}
Program is a loaded component: its core modules compiled, its wiring checked, ready to run once in the runtime it was loaded into.
func Load ¶
Load parses and checks a component and compiles its core modules in rt. Every import is resolved here, so a component that imports something TAP does not provide is refused before any of it runs.