Skip to main content

Module distributed_bus

Module distributed_bus 

Source
Expand description

Clustered live distribution via Postgres LISTEN/NOTIFY — the doorbell.

The owner replica appends an event to Postgres (durable), then NOTIFY prospero_events '<stream_key>:<seq>'. The payload is a pointer, not the event, so it sidesteps NOTIFY’s ~8 KB cap and keeps Postgres the single source of truth. A subscriber on any replica holds one LISTEN connection; on each doorbell for its stream it replays the delta from the durable store. See the topology design spec §3.2; clustered mode is durable-first (§4) — the live tail carries only what is durable.

Scaling note: each subscribe holds one dedicated LISTEN connection from this bus’s pool for the subscription’s lifetime, so live subscribers and pool connections grow 1:1. The daemon gives the bus its own pool (the clustered seams use a pool each today; a single shared pool is a future tuning option), sized by DistributedBus::connect for the expected concurrent SSE fan-out. If that ceiling is ever hit, multiplex one listener across streams — deferred until measured.

Structs§

DistributedBus
Clustered EventBus: a doorbell over the durable store (spec §3.2).