Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/frequenz/dispatch/_actor_dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ class DispatchInfo:
options: dict[str, Any]
"""Additional options."""

duration: timedelta | None
"""The duration of the dispatch."""

Comment on lines 32 to +37
Copy link
Contributor

Choose a reason for hiding this comment

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

Just suggestion: duration can be in options dict.
However I don't know why you need this so feel free to ignore this comment.


class ActorDispatcher(BackgroundService):
"""Helper class to manage actors based on dispatches.
Expand Down Expand Up @@ -229,6 +232,7 @@ async def _start_actor(self, dispatch: Dispatch) -> None:
components=dispatch.target,
dry_run=dispatch.dry_run,
options=dispatch.payload,
duration=dispatch.duration,
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 tricky and can be misleading. If you use the high-level interface and you are listening to the start/stop events, or your actor is managed, this duration might not match the time your actor is really running if some dispatches were merged.

I think a better approach would be to include a list of active dispatches, and just pass the full Dispatch object there. Another approach would be to pass here a "merged duration" instead of the raw duration of the current dispatch. Depending on the use case one could be more useful than the other.

Copy link
Contributor

Choose a reason for hiding this comment

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

I moved the conversation to #119, I think it is more appropriate to discuss the design in the issue.

)

identity = self._dispatch_identity(dispatch)
Expand Down