Expand description
Relaying broadcasts back into the sockets this process holds.
rainier-websocket says, in its own documentation,
that a Rooms registry lives in one process’s memory and that two replicas
behind a load balancer therefore have two sets of rooms. This is the module
that stops that being true.
POST /orders/7/ship ─▶ replica A ─▶ Broadcasting ─▶ kafka topic
│
┌───────────────────┴────────────┐
▼ ▼
relay on replica A relay on replica B
│ │
its Rooms its Rooms
│ │
browsers browsersEvery replica publishes to the topic and every replica reads from it, including the one that published — which is what makes a broadcast reach a browser regardless of which replica served the request that caused it.
§Two processes or one
Nothing here needs a second deployment. spawn starts the relay inside
the web process, next to the sockets it feeds, so the whole of “broadcasting
that works behind a load balancer” is a Kafka topic and one line in a
provider.
Structs§
- Socket
FanOut - Delivers relayed broadcasts to the sockets in a
Roomsregistry.