Skip to content
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

Merged
merged 13 commits into from
Mar 12, 2024

Conversation

mjhuff
Copy link
Contributor

@mjhuff mjhuff commented Mar 11, 2024

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

  • Start up postman and start a protocol run using the desktop app's dev mode. You'll notice in the app-shell logs a lot of subscribe requests to a /run/:runId. Make note of that runId and in postman, subscribe to /runs/.
  • After the run concludes, start another protocol run. Verify that the previous run (the run you're subscribed to in Postman), receives a message containing unsubscribe: true.

Risk assessment

low

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).
@mjhuff mjhuff requested a review from a team March 11, 2024 13:04
@mjhuff mjhuff requested a review from a team as a code owner March 11, 2024 13:04
Copy link
Member

@DerekMaggio DerekMaggio left a 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.

@mjhuff mjhuff requested a review from a team March 11, 2024 16:06
@mjhuff mjhuff requested a review from a team March 11, 2024 17:49
Copy link
Member

@sfoster1 sfoster1 left a 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.

@mjhuff mjhuff requested a review from sfoster1 March 11, 2024 22:34
Copy link
Member

@sfoster1 sfoster1 left a 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!

@mjhuff mjhuff added the DO NOT MERGE Indicates a PR should not be merged, even if there's a shiny green merge button available label Mar 12, 2024
@mjhuff
Copy link
Contributor Author

mjhuff commented Mar 12, 2024

Will merge alongside #14640

@mjhuff mjhuff removed the DO NOT MERGE Indicates a PR should not be merged, even if there's a shiny green merge button available label Mar 12, 2024
@mjhuff mjhuff merged commit e52658e into edge Mar 12, 2024
11 checks passed
@mjhuff mjhuff deleted the robot-server_add-unsubscribe-flag-notifications branch March 12, 2024 19:54
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.

None yet

3 participants