Configuration

The DS server supports layered TOML configuration plus env-var overrides.

Load order (later wins):

  1. built-in defaults
  2. config/default.toml (if present)
  3. config/<profile>.toml (if present; selected with --profile)
  4. config/local.toml (if present; intended for local overrides)
  5. --config <path> override file
  6. environment variables

CLI options:

FlagDescription
--profile <name>Loads config/<name>.toml
--config <path>Loads an additional TOML file last

Sample config files in this repo:

  • config/default.toml (baseline defaults)
  • config/dev.toml (development overrides)
  • config/prod.toml (production example)

Example:

cargo run -- --profile dev
cargo run -- --profile prod --config /etc/durable-streams/override.toml

Environment variables use the DS_ prefix with double-underscore section separators (e.g., DS_SERVER__PORT).

Server

VariableDefaultDescription
DS_SERVER__PORT4437TCP port to listen on
DS_HTTP__CORS_ORIGINS*Allowed CORS origins. * allows all. Multiple origins can be comma-separated (e.g., https://app.example.com,https://admin.example.com).
RUST_LOGinfoLog level filter (tracing format: debug, info, warn, error, or per-module like durable_streams=debug). Takes precedence over DS_LOG__RUST_LOG.
DS_LOG__RUST_LOGinfoDefault log level filter, applied through the TOML config layer. Overridden by RUST_LOG when both are set.

Transport (optional direct TLS)

VariableDefaultDescription
DS_TLS__CERT_PATHunsetPath to PEM certificate for direct TLS termination. Must be set together with DS_TLS__KEY_PATH.
DS_TLS__KEY_PATHunsetPath to PEM/PKCS#8 private key for direct TLS termination. Must be set together with DS_TLS__CERT_PATH.

Protocol

VariableDefaultDescription
DS_SERVER__LONG_POLL_TIMEOUT_SECS30How long to hold a long-poll request before returning 204 No Content. Set lower (e.g., 2) for fast-feedback testing.
DS_SERVER__SSE_RECONNECT_INTERVAL_SECS60SSE reconnect interval in seconds (matches Caddy's sse_reconnect_interval). Enables CDN request collapsing. Set to 0 to disable.

Memory limits

VariableDefaultDescription
DS_LIMITS__MAX_MEMORY_BYTES104857600 (100 MB)Maximum total memory across all streams. Appends exceeding this return 413 Payload Too Large.
DS_LIMITS__MAX_STREAM_BYTES10485760 (10 MB)Maximum bytes per individual stream.

Storage

VariableDefaultDescription
DS_STORAGE__MODEmemoryStorage backend mode: memory, file-fast, file-durable, acid (alias: redb).
DS_STORAGE__DATA_DIR./data/streamsRoot directory for persistent backends (file-*, acid).
DS_STORAGE__ACID_SHARD_COUNT16Number of redb shards when DS_STORAGE__MODE=acid; must be power-of-2 in 1..=256 (invalid values return an error).

Sync service (e2e stack)

These variables configure the sync service container, not the DS server itself:

VariableDefaultDescription
ELECTRIC_URLhttp://electric:3000Electric SQL Shape API base URL
DS_SERVER_URLhttp://server:4437DS server URL (internal Docker network)
POSTGRES_URLpostgresql://postgres:password@postgres:5432/durable_streamsPostgres connection string

Example

# Development (fast timeouts for testing)
DS_SERVER__LONG_POLL_TIMEOUT_SECS=2 DS_SERVER__SSE_RECONNECT_INTERVAL_SECS=5 cargo run

# Development profile from TOML
cargo run -- --profile dev

# Production (restricted CORS, custom port)
DS_SERVER__PORT=8080 DS_HTTP__CORS_ORIGINS=https://app.example.com cargo run

# Optional direct TLS (proxy->server encryption or direct serving)
DS_TLS__CERT_PATH=/etc/ds/tls/server.crt DS_TLS__KEY_PATH=/etc/ds/tls/server.key cargo run

# Debug logging
RUST_LOG=debug cargo run