Skip to main content

Crate barbacane_wasm

Crate barbacane_wasm 

Source
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_upgrade host function (ADR-0026).

Structs§

BodyAccessControl
Holds the split state: body-less JSON metadata and the raw body bytes.
Capabilities
Plugin capabilities from the [capabilities] section.
CircuitBreaker
Circuit breaker for a single upstream.
CircuitBreakerConfig
Circuit breaker configuration.
ConfigSchema
A compiled config schema for validating plugin configurations.
HttpClient
HTTP client with connection pooling and circuit breaker support.
HttpClientConfig
Configuration for the HTTP client.
HttpRequest
HTTP request from WASM plugin.
HttpResponse
HTTP response to WASM plugin.
InstanceKey
Key for identifying a plugin instance.
InstancePool
Pool of WASM plugin instances.
MiddlewareChain
A middleware chain that executes multiple middlewares in sequence.
MiddlewareConfig
A configured middleware in the chain.
PluginInstance
A WASM plugin instance ready for execution.
PluginLimits
Resource limits for plugin execution.
PluginManifest
A parsed and validated plugin manifest.
PluginMeta
Plugin metadata from the [plugin] section.
Request
Re-export plugin SDK types for convenience. An HTTP request as seen by plugins.
RequestContext
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.
WasmEngine
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.
ChainResult
Result of executing the full request chain.
CircuitState
Circuit breaker state.
HttpClientError
HTTP client errors.
OnRequestResult
The result of executing on_request on a single middleware.
PluginType
Plugin type.
StreamEvent
Events sent through the streaming channel by host_http_stream (ADR-0023).
TlsConfigError
TLS configuration errors.
TrapContext
The context in which a WASM trap occurred.
TrapResult
The result of handling a WASM trap.
WasmError
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§

MetricsCallback
Callback for recording middleware metrics. Parameters: middleware_name, phase (“request” or “response”), duration_secs, short_circuit