Skip to content

feat: Draft: Session status notification stream#650

Draft
plpn90 wants to merge 7 commits into
aneoconsulting:mainfrom
plpn90:dev/session-status-evts
Draft

feat: Draft: Session status notification stream#650
plpn90 wants to merge 7 commits into
aneoconsulting:mainfrom
plpn90:dev/session-status-evts

Conversation

@plpn90
Copy link
Copy Markdown

@plpn90 plpn90 commented Dec 2, 2025

// DRAFT: also did some side modifications which i can undo before merge

Motivation

Needed a better way to observe changes to sessions being opened/modified/deleted, other than polling the ListSessions() endpoint on the SessionsService.

Description

Adds another endpoint on the EventsService to create a notification channel for session updates.

Impact

Similiar idea to how the ChangeStream is implemented for Results. Btw, maybe it is time to rethink how these notifications work. Wouldn't MessageQueues be a better alternative for notifying changes/updates to the system overall? Also makes it independent to MongoDB (and for it being mandatory to be a replicaset!)

Phil Pohlmann added 7 commits November 26, 2025 17:32
- removed the status filter
- removed oldStatus in response, as mongos implementation to provide
  prechange document isnt production ready
- instead of oldStatus, use a updateType, representing the reason for
  the update: created/updated/deleted
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Phil Pohlmann seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@plpn90 plpn90 changed the title Draft: Session status notification stream feat: Draft: Session status notification stream Dec 2, 2025
Copy link
Copy Markdown
Contributor

@aneojgurhem aneojgurhem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove changes unrelated to this PR

}
}

message SessionEventSubscriptionRequest { }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you look into Core, here is what happens with the GetEvents API.

gRPC client (EventSubscriptionRequest)


GrpcEventsService.GetEvents


WatchToGrpc.GetEvents

├─ Filter building (tasksFilter AND sessionId, resultsFilter AND sessionId)
|
├─ [parallel background tasks — all writing to Channel]
│ ├─ NewTask watcher ──► MongoDB change stream (Insert on TaskData)
│ ├─ TaskStatusUpdate watcher ──► MongoDB change stream (Update on Status)
│ ├─ NewResult watcher ──► MongoDB change stream (Insert on Result)
│ ├─ ResultStatusUpdate ──► MongoDB change stream (Update on Status)
│ ├─ ResultOwnerUpdate ──► MongoDB change stream (Update on OwnerTaskId)
│ ├─ Existing tasks (DB catch-up query)
│ └─ Existing results (DB catch-up query)


Channel (fan-in, unbounded)


channel.Reader.ReadAllAsync(cancellationToken)
│ yields one by one

GrpcEventsService → responseStream.WriteAsync(...)


gRPC client receives EventSubscriptionResponse stream

I think we should provide something similar for the sessions. The key parts are:

  • we need to filter sessions (use existing sessions_filter) so that you can choose what to look for. Possibly, there is quite a lot of sessions in the database. Filtering on creation date can be very useful.
  • As for tasks and results, i expect a NewSession Event that catch up with existing sessions in the data base then catch new additions
  • .. and a SessionStatusUpdate catching every new update.
  • NewSession and SessionStatusUpdate should be messages defined in the response and wrapped inside a oneof

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants