-
Notifications
You must be signed in to change notification settings - Fork 28
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
main: Slightly rework main hub and gui lifecycle. #356
Conversation
9e8d19e
to
e91ad5f
Compare
return nil | ||
} | ||
if err := runHub(ctx, hub); err != nil { | ||
// Ensure the GUI is signaled to shutdown. |
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.
Despite calling cancel here, the gui has no waitgroup (or any other mechanism of signalling that it has completed shutdown) so there is no guarantee that it will shutdown completely before the process terminates. Thats an existing problem though, and we can fix that in a later PR.
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.
Right. My hope is that separating it out like this helps show the problem with the current design where it passes the cancel func down deep into the innards of something that does not control the overall process and thus shouldn't be able to just pull the rug out from everything as it's doing now.
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.
Given that we expect this code to move again shortly, I've only given this PR a thorough read and not tested it very much. Will test more thoroughly once its closer to its final form.
This moves the creation of the context into the main code path, splits the creation logic for the hub and gui into independent funcs, and arranges for the main code path to create those instances and run them. Since the pool struct is no longer necessary, both it and the associated newPool func are removed. This approach is preferred because it provides the main code path with full control over the lifecycle of the context instead of stuffing it into a separate struct which makes it much harder to reason about and has ultimately led to the use of the cancel func deep in the innards of the hub which should not have that level of control since it is not the coordinator and thus does not have enough details to know when it's actually safe or even should be forcing a shutdown. This commit does not address the latter part since it will require more in-depth changes to decouple it properly. However, this is a good start at reducing the overly-tight coupling of the lifecycle that exists as a result.
e91ad5f
to
2e8153a
Compare
This is rebased on #355.
This moves the creation of the context into the main code path, splits the creation logic for the hub and gui into independent funcs, and arranges for the main code path to create those instances and run them.
Since the pool struct is no longer necessary, both it and the associated
newPool
func are removed.This approach is preferred because it provides the main code path with full control over the lifecycle of the context instead of stuffing it into a separate struct which makes it much harder to reason about and has ultimately led to the use of the cancel func deep in the innards of the hub which should not have that level of control since it is not the coordinator and thus does not have enough details to know when it's actually safe or even should be forcing a shutdown.
This commit does not address the latter part since it will require more in-depth changes to decouple it properly. However, this is a good start at reducing the overly-tight coupling of the lifecycle that exists as a result.