-
Notifications
You must be signed in to change notification settings - Fork 55
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
feat(overlord): allow adding external managers #273
feat(overlord): allow adding external managers #273
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.
Some brainstorming ideas for discussion.
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 don't think the approach taken here is suitable for a public-facing API.
A simpler approach I suggest: having separate func New(...) (*Overlord, error)
and func (*Overlord) Init() error
functions, then have a func (*Overlord) AddManager(StateManager) error
that we can simply call before o.Init()
.
What do you think?
I don't like letting the user of that code be bitten by forgetting Init or calling AddManager after Init. Right now Overlord is more or less RAII, let's keep it that way if possible. Here the only purpose of Init would be to ensure the TaskRunner is the last manager. With the changes I made to the StateEngine, Init is not necessary. You can AddManager in cmd_run as Fred suggested. |
This commit introduces StateEngine.SetTaskRunner and therefore relaxes the constraint on the ordering of the managers in the StateEngine. This change has made the inited field of Overlord obsolete: there is no reason to guard against adding managers after Overlord.New anymore. So the inited field has been removed too. In turn, the relaxing of the ordering allows sister projects to add managers to the Overlord. The Overlord of a given Daemon can now be reached using a method of Daemon, so the sister project can use this functionality on their own Daemon.
d167eb1
to
6c7589a
Compare
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.
There appears to be a linter failure in one of the tests.
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.
Excellent work on this @paul-rodriguez!
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.
It's a bit awkward, but I understand why the task runner is special, and this seems reasonable to me -- it's definitely nice and simple!
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.
Just for my own tracking, we've discussed this and the approach here is not going in a good direction as it's misusing the abstractions we have. Let's please get together and figure a better way to do this.
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.
Looks great Paul. I think this is perfect for a first round of reviews, including a proposal discussion with Gustavo. I've taken the liberty to update the example in the PR description for a quick highlight of this scheme for understanding the proposal.
Current status: Further discussions required. Current design unlikely to progress in its current form. |
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.
Great! Added a few nitty and minor comments, as I think we may have time to do a detailed code review during our next meeting.
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.
Great work Paul. Looks super nice.
Regarding the PR description example, feel free to remote it or change it if you want. I find it essential assisting reviewers get the complete picture for things talking about some hypothetical external use-case (especially when discussing in person), but do not feel like we have to keep it there, or that version of it.
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.
This seems reasonable to me. Couple of comments about comments.
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.
Stellar work on this Paul, thank you!
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.
Thank you, that turned out well. Only documentation tuning suggested below.
Last two corrections added. Approved by Gustavo. Merging. |
This change enables an external application importing Pebble to extend the overlord functionality by adding additional managers.
Example overlord extension:
Example startup code:
External HTTP request handler example: