-
Notifications
You must be signed in to change notification settings - Fork 70
Open
Milestone
Description
Maintaining connection state is just part of the story - RIG is also about keeping track of who is online, that is, users and their devices/frontends/connections.
Terminology
- A session is identified by the JWT's ID claim (jti). Consequently, connections not associated with a JWT do not belong to any session.
- All connections a user creates with a single JWT (same jti) belong to the same session. Likewise, a user using multiple JWTs (different jti) can create connections that belong to different sessions. RIG has no notion of user, but instead handles sessions only.
Note: The
Session
module introduced by #217 is specific to the longpolling feature and it's meaning is not related to what is described here.
Implementation details
- One session manager per node
- Conn procs send heartbeat to their local manager
- Heartbeats contains remote socket and decoded JWTs, if available
- Session managers adds heartbeat info to DeltaCrdt.AWLWWMap
- Session manager join pg2 group and periodically sets up delta_crdt neighbors using that group
Note: If this works well, we should probably follow up with using the same technique for filter supervisors - currently, conn procs periodically refresh subscriptions with all filter supervisors, but it probably suffices to tell only the local one and let delta_crdt take care of state dissemination.
The Session Manager
- receives blacklist requests
- checks jwt expiration
- sends connection termination messages
- publishes “user/device went online (+jwt +nConnections)” and “user/device went offline (+jwt +reason)” events to kafka
- provides the list of online users/connections to :rig_api
Session API
- How many connections are associated to a session?
Possible enhancements to the Session API a.k.a. open issues
- Is user x online? <-- to answer this, we'd need a relation between JWT IDs and user IDs. Perhaps provide an endpoint to query for sessions that have a certain property set in their associated JWT?
- Who is online? <-- same thing here: easy to do for sessions, but we'd have to use configuration or a query parameter to extract the user ID from the associated JWTs.
- Also: Do we need to find out about the online state of users with certain properties?
Metadata
Metadata
Assignees
Labels
No labels