Skip to content

Backends

Backends store and distribute streaming events. The choice of backend affects durability, scalability, and whether events survive process restarts.

BackendValueBest forPersistence
Memory"memory"Development, single-instanceNo — events lost on restart
Redis"redis"Production, multi-instanceYes — events stored in Redis Streams
streaming:
backend: memory

No additional configuration needed. Events are stored in Python dicts and distributed via asyncio.Queue.

  • InMemoryBackend stores events in _events dict (keyed by run_id)
  • Subscribers receive events via asyncio.Queue instances per subscriber
  • Events are trimmed to max_events_per_run (default from EventBusFactory)
  • When the process restarts, all events are lost
  • Single-process only — subscribers must be in the same Python process
  • No event persistence — disconnected clients cannot replay past events from a previous session
  • Memory usage grows with event volume
streaming:
backend: redis
redis:
url: ${REDIS_URL:-redis://localhost:6379}
stream_ttl_seconds: 3600
max_events_per_run: 1000
connection_pool_size: 10
FieldTypeDefaultRangeDescription
urlstring"${REDIS_URL}"Redis connection URL
stream_ttl_secondsint360060–604800How long to retain events in Redis
max_events_per_runint100010–100000Max events stored per run
connection_pool_sizeint10Redis connection pool size
  • RedisBackend uses Redis Pub/Sub for real-time event distribution
  • Events are also stored in Redis Streams (via XADD) for replay
  • stream_ttl_seconds sets the Redis EXPIRE on stream keys
  • Subscribers receive events via Pub/Sub; replay uses XRANGE
  • Multi-process safe — any instance can publish, any instance can subscribe

The Redis backend requires the aioredis library (or redis with async support). If not installed, the backend falls back to memory.

If backend: redis is set but the redis sub-config is missing, the schema auto-creates a RedisStreamingConfig() with defaults:

# This:
streaming:
backend: redis
# Is equivalent to:
streaming:
backend: redis
redis:
url: "${REDIS_URL}"
stream_ttl_seconds: 3600
max_events_per_run: 1000
connection_pool_size: 10
CriterionMemoryRedis
SetupZero configRequires Redis instance
Multi-processNoYes
Event replaySame session onlyAcross restarts
Suitable for productionSingle-instance onlyYes
LatencyLowestSlightly higher (network)

Source: InMemoryBackend in packages/events/dockrion_events/backends/memory.py; RedisBackend in packages/events/dockrion_events/backends/redis.py; RedisStreamingConfig in packages/schema/dockrion_schema/dockfile_v1.py


Previous: Event Types | Next: StreamContext →