Expand description
§durable-streams-server
durable-streams-server is a Rust implementation of the
Durable Streams protocol,
built with axum and tokio.
It can be run as a standalone HTTP server or embedded into an existing axum
application with build_router or build_router_with_ready.
§Features
- Durable Streams HTTP API with create, append, read, head, close, and delete operations
- Live reads via long-polling and Server-Sent Events (SSE)
- In-memory, file-backed, and ACID (
redb) storage backends - Layered configuration from TOML files and
DS_*environment variables - Structured
application/problem+jsonerror responses - Request telemetry via
tracingwith OpenTelemetry/ECS-friendly field names
§Running
From the workspace root:
cargo run -p durable-streams-serverBy default the server listens on http://localhost:4437, exposes health checks
at /healthz and /readyz, and mounts the protocol at /v1/stream.
Use http.stream_base_path or DS_HTTP__STREAM_BASE_PATH to mount the
protocol at another path.
§Storage Backends
The default storage mode is in-memory. For persistence, choose a backend via
DS_STORAGE__MODE:
| Mode | Durability | Use case |
|---|---|---|
memory | None (lost on restart) | Development and testing |
file-fast | Buffered writes | Lower-latency persistence where recent data loss is acceptable |
file-durable | Fsynced writes | Durable persistence without external dependencies |
acid | Crash-resilient (redb) | Production workloads requiring transactional durability |
Examples:
DS_STORAGE__MODE=file-durable DS_STORAGE__DATA_DIR=./data cargo run -p durable-streams-server
DS_STORAGE__MODE=acid DS_STORAGE__DATA_DIR=./data cargo run -p durable-streams-server§Configuration
Configuration is loaded in this order, with later sources overriding earlier ones:
- Built-in defaults
config/default.tomlconfig/<profile>.tomlconfig/local.toml--config <path>- Environment variables
Examples:
cargo run -p durable-streams-server -- --profile prod
cargo run -p durable-streams-server -- --profile prod --config /etc/durable-streams/server.tomlCommon environment variables:
DS_SERVER__PORTDS_SERVER__LONG_POLL_TIMEOUT_SECSDS_SERVER__SSE_RECONNECT_INTERVAL_SECSDS_HTTP__CORS_ORIGINSDS_HTTP__STREAM_BASE_PATHDS_LIMITS__MAX_MEMORY_BYTESDS_LIMITS__MAX_STREAM_BYTESDS_STORAGE__MODEDS_STORAGE__DATA_DIRDS_STORAGE__ACID_SHARD_COUNTDS_STORAGE__ACID_BACKENDDS_TLS__CERT_PATHDS_TLS__KEY_PATHDS_LOG__RUST_LOGRUST_LOG
§Library Use
For embedding, the main entry points are:
ConfigandConfigLoadOptionsfor configuration loadingbuild_routerandbuild_router_with_readyfor mounting the HTTP APIInMemoryStorage,FileStorage, andAcidStoragefor backend selection
§Verification
cargo build -p durable-streams-server
cargo test -p durable-streams-server
cargo clippy -p durable-streams-server --all-targets
cargo fmt --all§Library Entry Points
Most embedders only need:
ConfigandConfigLoadOptionsto load server configurationbuild_routerto mount the Durable Streams HTTP API into an axum appStorageplus one ofInMemoryStorage,FileStorage, orAcidStorageto choose a persistence backend
The lower-level protocol module exposes types that are useful in tests,
storage implementations, and conformance-oriented integrations.
Re-exports§
pub use config::Config;pub use config::ConfigLoadOptions;pub use config::StorageMode;pub use router::DEFAULT_STREAM_BASE_PATH;pub use router::ShutdownToken;pub use router::build_router;pub use router::build_router_with_ready;pub use storage::Storage;pub use storage::acid::AcidStorage;pub use storage::file::FileStorage;pub use storage::memory::InMemoryStorage;