Expand description
WASM plugin runtime for Barbacane API gateway.
This crate provides the wasmtime-based runtime for loading and executing WASM plugins (middlewares and dispatchers) according to SPEC-003.
Re-exports§
pub use secrets::collect_secret_references;pub use secrets::is_secret_reference;pub use secrets::resolve_all_secrets;pub use secrets::resolve_config_secrets;pub use secrets::resolve_secret;pub use secrets::SecretsError;pub use secrets::SecretsStore;pub use rate_limiter::RateLimitResult;pub use rate_limiter::RateLimiter;pub use rate_limiter::RateLimiterStats;pub use cache::CacheEntry;pub use cache::CacheResult;pub use cache::CacheStats;pub use cache::ResponseCache;pub use broker::BrokerError;pub use broker::BrokerMessage;pub use broker::PublishResult;pub use kafka_client::KafkaPublisher;pub use nats_client::NatsPublisher;pub use ws_client::UpstreamWsStream;
Modules§
- broker
- Shared types for message broker dispatch (Kafka, NATS).
- cache
- Response cache with TTL support.
- crypto
- Cryptographic signature verification for WASM plugin host functions.
- kafka_
client - Kafka publisher for the Barbacane gateway.
- nats_
client - NATS publisher for the Barbacane gateway.
- rate_
limiter - Rate limiter with sliding window algorithm.
- secrets
- Secrets resolution for WASM plugins.
- version
- Plugin version resolution.
- ws_
client - WebSocket client for the
host_ws_upgradehost function (ADR-0026).
Structs§
- Body
Access Control - Holds the split state: body-less JSON metadata and the raw body bytes.
- Capabilities
- Plugin capabilities from the [capabilities] section.
- Circuit
Breaker - Circuit breaker for a single upstream.
- Circuit
Breaker Config - Circuit breaker configuration.
- Config
Schema - A compiled config schema for validating plugin configurations.
- Http
Client - HTTP client with connection pooling and circuit breaker support.
- Http
Client Config - Configuration for the HTTP client.
- Http
Request - HTTP request from WASM plugin.
- Http
Response - HTTP response to WASM plugin.
- Instance
Key - Key for identifying a plugin instance.
- Instance
Pool - Pool of WASM plugin instances.
- Middleware
Chain - A middleware chain that executes multiple middlewares in sequence.
- Middleware
Config - A configured middleware in the chain.
- Plugin
Instance - A WASM plugin instance ready for execution.
- Plugin
Limits - Resource limits for plugin execution.
- Plugin
Manifest - A parsed and validated plugin manifest.
- Plugin
Meta - Plugin metadata from the [plugin] section.
- Request
- Re-export plugin SDK types for convenience. An HTTP request as seen by plugins.
- Request
Context - Per-request context passed to plugins.
- Response
- Re-export plugin SDK types for convenience. An HTTP response as produced by plugins.
- TlsConfig
- TLS configuration for upstream mTLS connections.
- Wasm
Engine - The WASM engine that compiles and manages plugin modules.
Enums§
- Action
- Re-export plugin SDK types for convenience.
The action a middleware returns from
on_request. - Chain
Result - Result of executing the full request chain.
- Circuit
State - Circuit breaker state.
- Http
Client Error - HTTP client errors.
- OnRequest
Result - The result of executing on_request on a single middleware.
- Plugin
Type - Plugin type.
- Stream
Event - Events sent through the streaming channel by
host_http_stream(ADR-0023). - TlsConfig
Error - TLS configuration errors.
- Trap
Context - The context in which a WASM trap occurred.
- Trap
Result - The result of handling a WASM trap.
- Wasm
Error - Errors that can occur in the WASM runtime.
Functions§
- execute_
on_ request - Execute the on_request chain.
- execute_
on_ request_ with_ metrics - Execute the on_request chain with optional metrics recording.
- execute_
on_ response - Execute the on_response chain.
- execute_
on_ response_ partial - Execute on_response for a partial chain (after short-circuit).
- execute_
on_ response_ with_ metrics - Execute the on_response chain with optional metrics recording.
- parse_
middleware_ output - Parse middleware output to determine the action.
- validate_
exports - Validate that a WASM module exports the required functions for its type.
- validate_
imports - Validate that a WASM module only imports declared host functions.
Type Aliases§
- Metrics
Callback - Callback for recording middleware metrics. Parameters: middleware_name, phase (“request” or “response”), duration_secs, short_circuit