Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
## Upgrading

* The `key` parameter in the `Dispatcher` constructor is now deprecated. Use `auth_key` instead. The `sign_secret` parameter is an additional optional parameter for signing.
* The `components` property in `DispatchInfo` is now deprecated. Use `target` instead.

## New Features

Expand Down
17 changes: 14 additions & 3 deletions src/frequenz/dispatch/_actor_dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from frequenz.client.dispatch.types import DispatchId, TargetComponents
from frequenz.core.id import BaseId
from frequenz.sdk.actor import Actor, BackgroundService
from typing_extensions import deprecated

from ._dispatch import Dispatch

Expand All @@ -37,8 +38,18 @@ def __init__(self, dispatch_id: DispatchId | int) -> None:
class DispatchInfo:
"""Event emitted when the dispatch changes."""

components: TargetComponents
"""Components to be used."""
@property
@deprecated("'components' is deprecated, use 'target' instead.")
def components(self) -> TargetComponents:
"""Get the target components.

Deprecation: Deprecated in v0.10.3
Use [`target`][frequenz.dispatch.DispatchInfo.target] instead.
"""
return self.target

target: TargetComponents
"""Target components to be used."""

dry_run: bool
"""Whether this is a dry run."""
Expand Down Expand Up @@ -200,7 +211,7 @@ def start(self) -> None:
async def _start_actor(self, dispatch: Dispatch) -> None:
"""Start the actor the given dispatch refers to."""
dispatch_update = DispatchInfo(
components=dispatch.target,
target=dispatch.target,
dry_run=dispatch.dry_run,
options=dispatch.payload,
_src=dispatch,
Expand Down
6 changes: 2 additions & 4 deletions tests/test_managing_actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,7 @@ async def test_simple_start_stop(

event = test_env.actor(1).initial_dispatch
assert event.options == {"test": True}
assert event.components == TargetIds(
ComponentId(1), ComponentId(10), ComponentId(15)
)
assert event.target == TargetIds(ComponentId(1), ComponentId(10), ComponentId(15))
assert event.dry_run is False

assert test_env.actor(1).is_running is True
Expand Down Expand Up @@ -309,7 +307,7 @@ async def test_dry_run(test_env: _TestEnv, fake_time: time_machine.Coordinates)
event = test_env.actor(1).initial_dispatch

assert event.dry_run is dispatch.dry_run
assert event.components == dispatch.target
assert event.target == dispatch.target
assert event.options == dispatch.payload
assert test_env.actor(1).is_running is True

Expand Down