-
Notifications
You must be signed in to change notification settings - Fork 175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(robot-server): Utilize unsubscribe flags for dynamic topics #14620
refactor(robot-server): Utilize unsubscribe flags for dynamic topics #14620
Conversation
This is the robot-server groundwork required to refactor MQTT client subscription logic. Instead of relying on the app-shell's ConnectionManager to determine topic subscription status based on component interest, we greatly reduce the notification system's complexity and bug surface by requiring the robort-server to broadcast an unsubscribe flag for dynamic topics (ex, /runs/:runId). The tradeoff here is the app may be subscribed to topics it actually has no interest in, but the overhead for this is insigificant: occasional refetch flags sent by the robot-server that the client doesn't do anything with (in fact, no longer does the client need to send repeated unsubscribe then subsequent resubscribe packets).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unsubscribing from the run after it is finished makes sense to me, as that run shouldn't be receiving any updates, so it makes no sense to keep listening for events.
robot-server/robot_server/service/notifications/publishers/runs_publisher.py
Show resolved
Hide resolved
robot-server/robot_server/service/notifications/publishers/runs_publisher.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should refactor this so we don't have a function with a boolean flag that drastically alters its semantics.
robot-server/robot_server/service/notifications/notification_client.py
Outdated
Show resolved
Hide resolved
robot-server/robot_server/service/notifications/publishers/runs_publisher.py
Outdated
Show resolved
Hide resolved
robot-server/robot_server/service/notifications/publishers/runs_publisher.py
Outdated
Show resolved
Hide resolved
robot-server/robot_server/service/notifications/publishers/runs_publisher.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making the changes, LGTM!
Will merge alongside #14640 |
Closes EXEC-305
Overview
This PR adds unsubscribe flags for dynamic notification topics, e.g. "/runs/:runId".
Now that the dust has settled around what our push notification can (and can’t) do, it’s clear that the burden of unsubscribing should be on the robot-server, specifically for dynamic topics.
In other words, it’s ok for the app to connect to a broker and remain subscribed to topics that will never change, ex. “/maintenance_runs/current_run” (and be subscribed to those topics as long as the app is connected). Dynamic topics, such as “/runs/:runId”, should tell the app to unsubscribe however, as requiring the broker to stores these topics unnecessarily increases memory load on the robot server during long-lived sessions.
This model is much easier to reason about as opposed to the component interest model that we use now. Bug surface is reduced, too.
Test Plan
unsubscribe: true
.Risk assessment
low