-
Couldn't load subscription status.
- Fork 6
Interface enhancements #89
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
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.
Except for the to actor or not to actor question, LGTM.
tests/test_frequenz_dispatch.py
Outdated
| # pylint: disable=protected-access | ||
| actor._restart_limit = 0 |
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.
Maybe we should expose these fixtures publicly in the SDK in some test package?
https://github.com/frequenz-floss/frequenz-sdk-python/blob/v1.x.x/tests/conftest.py
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.
Could be useful, yes
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.
src/frequenz/dispatch/_dispatcher.py
Outdated
| # pylint: disable=redefined-builtin | ||
| def new_lifecycle_events_receiver(self, type: str) -> Receiver[DispatchEvent]: |
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.
Super minor but maybe call it dispatch_type instead of just type?
src/frequenz/dispatch/_dispatcher.py
Outdated
| A new receiver for new dispatches. | ||
| """ | ||
| return self._lifecycle_events_channel | ||
| return self._actor.new_lifecycle_events_receiver(type) |
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 is not following the actor model. You should only interact with an actor via channels, not calling methods.
I'm OK with keeping this approach though, as if we go multi-node at some point, probably having one dispatch-cache per mode is desirable, so all communication with the actor instance can be local. And also it is probably not worth adding the complexity needed to keep this as an actor at this point.
I just think we need to stop calling this an actor and inherit directly from BackgroundService instead, it is confusing otherwise.
e7514f4 to
49dba68
Compare
src/frequenz/dispatch/_bg_service.py
Outdated
| class DispatchingActor(Actor): | ||
| """Dispatch actor. | ||
| # pylint: disable=too-many-instance-attributes | ||
| class DispatchBackgroundService(BackgroundService): |
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.
Minor: maybe call it DispatchScheduler?
Signed-off-by: Mathias L. Baumann <[email protected]>
This allows us to control what happens when a new receiver is created. In this case we want to send all relevant running state events to each new receiver. It won't hurt us that other receivers might get them as well as it would just repeat the states they already know of. Signed-off-by: Mathias L. Baumann <[email protected]>
Signed-off-by: Mathias L. Baumann <[email protected]>
|
Updated to lucas tiny remaining feedback, will force-merge now |
This also fixes #87