Crate sentinel_agent_wasm

Crate sentinel_agent_wasm 

Source
Expand description

Sentinel WebAssembly Agent Library

A WebAssembly agent for Sentinel reverse proxy that executes Wasm modules for request/response processing. Modules can be written in any language that compiles to WebAssembly (Rust, Go, C, AssemblyScript, etc.).

§Wasm Module ABI

Modules must export the following functions:

// Memory allocation (required)
alloc(size: i32) -> i32          // Allocate `size` bytes, return pointer
dealloc(ptr: i32, size: i32)     // Free memory at `ptr`

// Request/Response handlers (at least one required)
on_request_headers(ptr: i32, len: i32) -> i64   // Returns (result_ptr << 32) | result_len
on_response_headers(ptr: i32, len: i32) -> i64  // Returns (result_ptr << 32) | result_len

The host passes JSON data to the module and expects JSON back.

Structs§

WasmAgent
WebAssembly agent
WasmConfigJson
Configuration JSON for Wasm agent
WasmRequest
Request data passed to Wasm module
WasmResponse
Response data passed to Wasm module
WasmResult
Result from Wasm module execution