feat(sse): per-connection filtering with user and workstation context #162
Reference in New Issue
Block a user
Delete Branch "%!s()"
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?
Context
Sub-issue of #125 (Context-Aware Part Subscription System).
The current SSE broker (
internal/api/broker.go) is a pure fan-out: every connected client receives every event. For edit sessions and subscriptions we need:Current Broker
No identity.
Publish()fans out to all clients. ~130 lines total.Changes
1. Extend
sseClientwith context2. Extend
Subscribe()signatureThe SSE handler (
HandleEvents) extracts userID from auth context and workstationID from?workstation_id=query param. CallsTouch()on the workstation to updatelast_seen.3. Add item subscription methods
Called by edit session handlers when a session is acquired/released. Could also be called explicitly by clients via a future endpoint.
4. Add targeted publish methods
The existing
Publish()(broadcast) remains for global events likeheartbeat,server.state,item.created, etc.5. Update
HandleEventsIn
internal/api/sse_handler.go:6. History replay filtering
EventsSince()currently replays all events. For targeted events, either:Eventstruct and filter on replayRecommend: only replay broadcast events. Targeted events are real-time only.
Files to Modify
internal/api/broker.go— extend sseClient, add targeted publish methodsinternal/api/sse_handler.go— pass identity on subscribeAcceptance Criteria
Publish()(broadcast) still works for all existing eventsPublishToItem()delivers only to clients with that item in their filterPublishToWorkstation()delivers only to matching workstationPublishToUser()delivers to all connections for a userlast_seenupdated on SSE connectDepends On
Part Of
#125