Expand description
Lock-free connection & broadcasting registry.
§Topology
The hot path for real-time servers is broadcast: one inbound event fans
out to thousands of sockets. A naive Mutex<HashMap<Id, Sender>> serialises
every send behind one lock — the classic C10K/C100K bottleneck.
arcly-http instead uses dashmap::DashMap, which shards the key space
across N independent locks (N = 4 * num_cpus by default). Two broadcasts
touching different shards never contend. Each connection owns a bounded
mpsc::Sender; sending is a wait-free try_send that never blocks the
frame-processing task. The per-socket writer drains its own receiver, and a
client that can’t keep up is evicted when its queue fills — a slow
consumer costs at most ws_outbound_buffer frames of memory, never an
unbounded buffer.
§Encapsulation
No axum/tower types appear here. The registry speaks WsMessage, an
arcly-owned enum. The websocket boundary in super::ws is the single
place that translates WsMessage ↔ axum::extract::ws::Message.
Structs§
- Connection
Registry - Sharded, lock-free-on-the-hot-path connection registry.
- WsClient
- A cheap, clonable handle to one connected client.
Enums§
- WsMessage
- An arcly-owned outbound frame. The websocket boundary maps this onto the
concrete transport frame type — keeping
axumout of the public surface.
Type Aliases§
- ConnId
- Monotonic, process-unique connection identifier.