Expand description
The WASM-to-unified-chain adapter (DW-119).
WasmChainAdapter bridges the proxy-wasm host’s per-request
PluginInstances into the unified crate::plugins::PluginChain
by implementing crate::plugins::WasmDispatch. The dataplane
constructs one adapter per request (holding the PluginInstances
for the route’s WASM plugins) and passes it to PluginChain::new;
the chain calls back into the adapter once per WASM entry per phase,
passing the entry’s NAME, and the adapter dispatches to exactly that
plugin’s instance (so a chain interleaving native filters and WASM
plugins in one phase runs each entry exactly once, in config order).
This module (and the whole proxy-wasm host) compiles unconditionally
in the OSS build — there are no cargo features for it. The unified
chain’s no-wasm adapter (crate::plugins::NoWasm) exists for
native-only chains and tests.
Dependency direction: wasm depends on plugins (downward —
plugins sits below wasm in the dependency table). The adapter
converts wasm::host::LocalResponse to
plugins::LocalResponse at the dispatch boundary, and attributes
traps to the named plugin so the dataplane can record
dwara_plugin_failures_total{name,reason} (DW-157).
§HTTP callouts: the pause/resume seam (DW-167)
When a phase dispatch ends with the plugin having registered
proxy_http_call callouts (PhaseResult::Pause), the adapter
records WHICH plugin paused and reports
ChainOutcome::CalloutPending up the chain; the chain stops and
the async driver in dataplane::plugin_dispatch takes over:
WasmChainAdapter::pending_calloutsdrains the paused instance’s queue (FIFO) as transport-readyCalloutRequests;- the driver performs each exchange off-thread
(
spawn_blockingaround the synchronous client) and records thedwara_plugin_callouts_total{name,outcome}metric; WasmChainAdapter::deliver_calloutre-enters the instance (synchronous wasmtime) withproxy_on_http_call_responseand returns the plugin’s resumed outcome — Continue, a local response, a trap, or anotherCalloutPending(the plugin dispatched again; the driver loops, bounded);- on Continue the driver reads the resumed plugin’s phase payload
back through this adapter and continues the chain from the entry
AFTER the paused one (
PluginChain::resume_*).
The wasm runner stays fully synchronous; only the driver awaits.
Structs§
- Wasm
Chain Adapter - The per-request WASM dispatch adapter.