2 unstable releases
Uses new Rust 2024
| new 0.28.0 | Feb 24, 2026 |
|---|---|
| 0.1.0-alpha.1 | Feb 11, 2026 |
#266 in WebAssembly
Used in 20 crates
(18 directly)
31KB
242 lines
Omnia Wasm Runtime
The Omnia Wasm runtime provides a thin wrapper around wasmtime for ergonomic integration of host-based services for WASI components.
It allows you to declaratively assemble a runtime that provides specific capabilities (like HTTP, Key-Value, Messaging) to guest components, backed by real host implementations.
Quick Start
Use the runtime! macro to configure which WASI interfaces and backends your host runtime needs. This generates a runtime_run function that handles the entire lifecycle.
use omnia::runtime;
use omnia_wasi_http::WasiHttpCtx;
use omnia_wasi_keyvalue::KeyValueDefault;
use omnia_wasi_otel::DefaultOtel;
// Define the runtime with required capabilities
omnia::runtime!({
"http": WasiHttpCtx,
"keyvalue": KeyValueDefault,
"otel": DefaultOtel,
});
#[tokio::main]
async fn main() -> anyhow::Result<()> {
// Parse command line arguments (provided by the macro-generated Cli)
let cli = Cli::parse();
// Run the runtime
runtime_run(cli).await
}
Core Traits
The runtime is built around a set of traits that allow services to be plugged in:
| Trait | Purpose |
|---|---|
Host<T> |
Links a WASI interface (e.g., wasi:http) into the wasmtime::Linker. |
Server<S> |
Starts a server (e.g., HTTP listener, NATS subscriber) to handle incoming requests. |
Backend |
Connects to an external service (e.g., Redis, Postgres) during startup. |
State |
Manages per-request state and provides access to the component instance. |
FromEnv |
Configures backend connections from environment variables. |
Features
jit(default): Enables Cranelift JIT compilation, allowing you to run.wasmfiles directly. Disable this to only support pre-compiled.bincomponents (useful for faster startup in production).
Configuration
The runtime and its included services are configured via environment variables:
RUST_LOG: Controls logging verbosity (e.g.,info,debug,omnia=trace).OTEL_GRPC_URL: Endpoint for OpenTelemetry collector (ifomnia-otelis used).
Architecture
See the workspace documentation for the full architecture guide and list of available WASI interface crates.
License
MIT OR Apache-2.0
Dependencies
~0–22MB
~275K SLoC