Files
wazero/examples/namespace
Crypt Keeper d108ce4c43 Restores ability to define host functions w/o context via reflection (#832)
This restores the ability to leave out the initial context parameter
when defining functions with reflection. This is important because some
projects are porting from a different library to wazero, and all the
alternatives are not contextualized.

For example, this project is porting envoy host functions, and the
original definitions (in mosn) don't have a context parameter. By being
lenient, they can migrate easier.

See 6b813482b6/pkg/proxywasm/wazero/imports_v1.go

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2022-10-28 12:44:12 -07:00
..

Stateful import example

This example shows how WebAssembly modules can import their own stateful host module, such as "env", in the same runtime.

$ go run counter.go
ns1 count=0
ns2 count=0
ns1 count=1
ns2 count=1

Specifically, each WebAssembly-defined module is instantiated alongside its own Go-defined "env" module in a separate wazero.Namespace. This is more efficient than separate runtimes as instantiation re-uses the same compilation cache.