Package org.mockserver.wasm
Class WasmRuntime
java.lang.Object
org.mockserver.wasm.WasmRuntime
Thin wrapper around a compiled chicory WASM instance.
Thread-safety: chicory Instance is NOT thread-safe, so the stored WASM
bytes are parsed into a WasmModule and a fresh Instance is
created for each invocation.
The WASM module must export a function match(i32 ptr, i32 len) -> i32
that reads len bytes from linear memory starting at ptr and
returns non-zero for a match.
This class fails closed: any error returns false.
-
Constructor Summary
ConstructorsConstructorDescriptionWasmRuntime(byte[] wasmBytes) Create a runtime with the default memory page limit fromConfigurationProperties.wasmMaxMemoryPages().WasmRuntime(byte[] wasmBytes, int maxMemoryPages) Create a runtime with an explicit memory page limit. -
Method Summary
-
Constructor Details
-
WasmRuntime
public WasmRuntime(byte[] wasmBytes) Create a runtime with the default memory page limit fromConfigurationProperties.wasmMaxMemoryPages(). -
WasmRuntime
public WasmRuntime(byte[] wasmBytes, int maxMemoryPages) Create a runtime with an explicit memory page limit.- Parameters:
wasmBytes- the compiled WASM binarymaxMemoryPages- maximum number of WASM linear memory pages (each page is 64 KiB)
-
-
Method Details
-
callMatch
Call the WASM module'smatch()function with the request body written into linear memory at offset 0.- Parameters:
requestBody- the HTTP request body (may be null)- Returns:
trueif the module'smatchfunction returns non-zero
-