Files
Messenger/docs/adr/0002-realtime-hub.md
T
vantablackTea 6fc6d977bf
CI / Go (build + vet + test) (push) Canceled after 0s
CI / Web (build + lint) (push) Canceled after 0s
added media fixes, search, push updates, pwa, metrics. preparing release 1.0
2026-09-27 23:26:15 +03:00

772 B

ADR 0002: In-memory WebSocket hub

  • Status: accepted
  • Date: 2026-09

Context

Realtime delivery (messages, typing, presence, read receipts) must reach connected clients immediately. Options: external broker (Redis pub/sub, NATS), Postgres LISTEN/NOTIFY, or an in-process hub.

Decision

Use an in-process hub: map[userID] -> connections plus map[conversationID] -> subscribers, guarded by a mutex. Membership and read-state are resolved through a MembershipProvider interface implemented by the store.

Consequences

  • Sub-millisecond fan-out, no extra moving parts.
  • Presence checks (IsOnline) are lock-free reads used by the push notifier.
  • Multi-node scaling would require a broker; the hub's publish methods are the seam where that would plug in.