Skip to content

Conversation

@Marenz
Copy link
Contributor

@Marenz Marenz commented Dec 19, 2024

  • Replace channel properties with receiver functions
  • Tests: Prevent inf actor restarts on exceptions

This also fixes #87

@Marenz Marenz requested a review from a team as a code owner December 19, 2024 10:14
@github-actions github-actions bot added part:docs Affects the documentation part:tests Affects the unit, integration and performance (benchmarks) tests part:actor Affects the dispatching actor part:dispatcher Affects the high-level dispatcher interface labels Dec 19, 2024
Copy link
Contributor

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

Comment on lines 74 to 75
# pylint: disable=protected-access
actor._restart_limit = 0
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be useful, yes

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 215 to 216
# pylint: disable=redefined-builtin
def new_lifecycle_events_receiver(self, type: str) -> Receiver[DispatchEvent]:
Copy link
Contributor

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?

A new receiver for new dispatches.
"""
return self._lifecycle_events_channel
return self._actor.new_lifecycle_events_receiver(type)
Copy link
Contributor

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.

@Marenz Marenz force-pushed the enhancefac branch 2 times, most recently from e7514f4 to 49dba68 Compare December 19, 2024 13:14
@Marenz Marenz requested a review from llucax December 19, 2024 14:00
llucax
llucax previously approved these changes Dec 20, 2024
class DispatchingActor(Actor):
"""Dispatch actor.
# pylint: disable=too-many-instance-attributes
class DispatchBackgroundService(BackgroundService):
Copy link
Contributor

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?

Marenz added 3 commits January 7, 2025 17:54
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]>
@Marenz
Copy link
Contributor Author

Marenz commented Jan 7, 2025

Updated to lucas tiny remaining feedback, will force-merge now

@Marenz Marenz merged commit 1c88c58 into frequenz-floss:v0.x.x Jan 7, 2025
14 checks passed
@Marenz Marenz deleted the enhancefac branch January 7, 2025 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

part:actor Affects the dispatching actor part:dispatcher Affects the high-level dispatcher interface part:docs Affects the documentation part:tests Affects the unit, integration and performance (benchmarks) tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Potentially lost dispatches on startup

2 participants