-
Notifications
You must be signed in to change notification settings - Fork 178
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(app-shell): Migrate desktop app notify connectivity to discovery-client #14648
Conversation
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 I understand what this is doing, but it's getting really confusing. There's a lot of free-variable associative stores at the file scope, robots can be in multiple of them at once, there's several different pending states.
I think a lot of this will be cleared up and also testable if you consolidate some of this into a single object or closure with a couple methods that move robots between states atomically. Then have a file-scope instance of that, and have the various actions and callbacks use it to move robots around. At that point, it's pure logic and testable.
…ndant connections
While testing I realized that I didn't account for the common scenario of discovery-client reporting multiple IPs for one robot (ethernet, wifi). We don't want multiple broker connections from the same app, since that's extremely inefficient. So the solution:
Anyway, I think this is ready for review again. Let me know your thoughts. I will add testing once we've decided we're ok with this (hopefully final) iteration of the connection manager. |
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.
More details in comments, but broad-strokes stuff:
- Since we appear to be focused on keeping one connection per broker, does it make sense to have the connection store have
robotNameByIp: Record<string, string>
andhostsByRobotName: Record<string, HostData>
? that way we don't have to do a search for matching hostnames every time.
Uh I submitted that too early I'll have followups |
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.
Ok. Fundamentally looks good to me but I think there's some refactors we can do for clarity.
c93702a
to
af12fbc
Compare
af12fbc
to
2fb099c
Compare
Closes EXEC-319 This is the app-shell-odd equivalent of the app-shell refactor, #14648. It's similar to the app-shell logic, but significantly simpler, since we don't have to manage multiple robots, worry about localhost port blocking, and multiple IPs per robot. The real change lies in the initial connect and final disconnect on app shutdown. Otherwise, the changes are primarily in the ConnectionStore. Because the app no longer utilizes unsubscribe actions in any capacity, we can safely remove those references.
Closes EXEC-319 This is the app-shell-odd equivalent of the app-shell refactor, #14648. It's similar to the app-shell logic, but significantly simpler, since we don't have to manage multiple robots, worry about localhost port blocking, and multiple IPs per robot. The real change lies in the initial connect and final disconnect on app shutdown. Otherwise, the changes are primarily in the ConnectionStore. Because the app no longer utilizes unsubscribe actions in any capacity, we can safely remove those references.
Closes EXEC-319 This is the app-shell-odd equivalent of the app-shell refactor, #14648. It's similar to the app-shell logic, but significantly simpler, since we don't have to manage multiple robots, worry about localhost port blocking, and multiple IPs per robot. The real change lies in the initial connect and final disconnect on app shutdown. Otherwise, the changes are primarily in the ConnectionStore. Because the app no longer utilizes unsubscribe actions in any capacity, we can safely remove those references.
Closes EXEC-304
Overview
Migrating MQTT connectivity logic to discovery-client simplifies app-shell connectionStore manager logic (maybe), reduces bug surface, and gives us connection retry logic relatively for free.
Most importantly, we will not depend on components to express interest in a broker and topics, which implicitly requires all components and notify helper functions in the app to behave appropriately (not re-render like crazy).
Note that there's some browser layer logic that is no longer relevant (like UNSUBSCRIBE actions), but these still need to be here until app-shell-odd is refactored. While the app still dispatches these actions, they don't actively do anything.
App-shell notifications behave as follows:
Test Plan
setInterval(() => {console.log(connectionStore)}, 1000)
withinnotify.ts
as this gives direct feedback on what's happening.Risk assessment
medium-ish. This is a pretty big refactor of how notifications work for the desktop app.