ryu-realtime
Room-keyed realtime fan-out primitive for Ryu. Part of Ryu.
ryu-realtime is the transport-agnostic fan-out core (Phase 1 of the multi-user collaboration epic) that chat fan-out, CRDT doc-sync, and presence/awareness all consume. It knows nothing about WebSockets, JWTs, or access control — those live in the Core WS handler that drives this registry.
Shape
RoomRegistrymapsroom_id→ aRoomHandle. Each live room runs as one tokio actor task (run_room) that owns the room's ephemeral state (presence map + idle clock) behind a command channel, plus a boundedtokio::sync::broadcastsender for fan-out.- Membership is reference-counted;
RoomHandle::joinreturns aRoomMembershipRAII guard whoseDropdecrements the count, evicts the member's presence, and broadcasts apresence_leavedelta — so a dropped socket is still reaped. - Hibernation — a room idle beyond
RoomConfig::idle_windowexits its actor and leaves the registry, rehydrating on next join (the main scaling lever). - Race safety — join's get-or-create +
fetch_addand the actor's eviction recheck take the same registryMutex, so no caller ever holds a handle to a dropped room. - Typed event contract — the
Frameenum overEvent/Presence/DocSyncchannels;publish_eventbroadcasts,subscribereturns a droppable receiver (= unsubscribe handle).
Role in the decomposition
An extracted Core capability crate consumed as a non-optional in-process path dependency — the chat fan-out path drives it directly, never over IPC. ZERO dependency on apps/core; it is a sibling to Core's identity_verify. The WS transport and any access control are the swap-seam boundary and stay Core-side.
Placement (CLAUDE.md §1): fan-out of live session state is what runs, so Core.
Build
License
Apache-2.0; see LICENSE. © 2026 A Major Pte. Ltd.