Skip to main content

Module source_host

Module source_host 

Source
Expand description

Source host state, linker functions, and host imports.

This module provides:

  • SourceHostState: host state for the source world (separate from WasmHostState)
  • SourceChannels: bounded tokio channels bridging async guest imports to host tasks
  • HostWithStore impl for async accept-http, submit-exchange; sync Host impl for is-cancelled
  • run_http_listener: async axum task feeding HTTP requests into the channel
  • run_pipeline_bridge: async task forwarding exchanges to the pipeline

Structs§

HttpListenerHandle
Concrete type for the http-listener resource in the ResourceTable. Stateless — the handle is a marker that the guest holds while running. Mapped via with: in source_bindings.rs to replace the empty enum generated by bindgen for the resource http-listener declaration.
HttpMeta
Materialized HTTP request metadata (everything except the body).
SourceChannels
Paired channel endpoints for bridging the guest to async host tasks.
SourceHostState
Host state for a source consumer. Lives inside the wasmtime::Store.

Constants§

DEFAULT_MAX_REQUEST_BODY_BYTES
Default maximum request body size in bytes (10 MiB).
EXCHANGE_CHANNEL_CAPACITY
Capacity for the exchange channel (guest → pipeline bridge). 1 enforces strict backpressure — guest blocks until pipeline accepts.
REQUEST_CHANNEL_CAPACITY
Capacity for the HTTP request channel (host listener → guest).

Functions§

add_to_linker
Register the source-host interface and WASI p2 into a linker for SourceHostState.
run_http_listener
Run an axum HTTP server that feeds incoming requests into request_tx.
run_pipeline_bridge
Receive native exchanges from the guest’s submit-exchange import and forward them to the pipeline via ConsumerContext.