events: SSE nudge stream, Federated and the bell update live (#476) #477
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix-476"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Per the #476 brief, TDD with red witnessed on the runner (stubs first, behavior tests failing, then the implementation).
internal/events: in-processHub— per-user fanout, buffered channels with drop-on-full (a publish never blocks a request handler), per-user cap of 4 streams,Countfor tests. Tests: fanout + unsubscribe cleanup, no cross-user leakage, drop-on-full does not block, cap enforcement.internal/api/events.go:GET /api/v1/events— session-authenticated SSE;text/event-stream,X-Accel-Buffering: no, 25s heartbeat comments, exits on client disconnect. Emitsevent: change/data: {"topic":"…"}nudges only; the client re-fetches REST endpoints it already trusts. Tests: full httptest round-trip (subscribe → publish → frame on the wire → disconnect frees the hub) and 401 without a session. The server sets no WriteTimeout (deliberate, per its own comment), so no deadline handling is needed.shareshandler nudges the recipient afterAddShareIn(via aService.Notifyclosure — no events import in package ocm);ocmShareInDecideand dismiss nudge the deciding user, so other tabs/devices sync.startEvents()opens the EventSource after boot; on anocmnudge it runspollBell()and, when the Federated view is on screen,fedReload(). The 60s poll stays as the fallback; closed streams retry with backoff (EventSource handles transient drops itself).Deferred (recorded here, not built):
cairn_sse_connectionsgauge,bell-topic publishers beyond OCM (peering inbox, licence), and an ocm-package integration test for the inbound nudge — the call site is a nil-guarded one-liner and the hub/handler carry the test load.Closes #476.