Skip to content
Open
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
4 changes: 2 additions & 2 deletions src/frequenz/dispatch/_actor_dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,15 @@ def _update_dispatch_information(self, dispatch_update: DispatchInfo) -> None:

async def main():
url = os.getenv("DISPATCH_API_URL", "grpc://dispatch.url.goes.here.example.com")
auth_key = os.getenv("DISPATCH_API_AUTH_KEY", "some-key")
key = os.getenv("DISPATCH_API_KEY", "some-key")
sign_secret = os.getenv("DISPATCH_API_SIGN_SECRET")

microgrid_id = 1

async with Dispatcher(
microgrid_id=microgrid_id,
server_url=url,
auth_key=auth_key,
key=key,
sign_secret=sign_secret,
) as dispatcher:
status_receiver = dispatcher.new_running_state_event_receiver("EXAMPLE_TYPE")
Expand Down
26 changes: 12 additions & 14 deletions src/frequenz/dispatch/_dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ async def run():
async with Dispatcher(
microgrid_id=microgrid_id,
server_url=url,
auth_key=key
key=key
) as dispatcher:
dispatcher.start_managing(
dispatch_type="DISPATCH_TYPE",
Expand All @@ -91,7 +91,7 @@ async def run():
async with Dispatcher(
microgrid_id=microgrid_id,
server_url=url,
auth_key=key
key=key
) as dispatcher:
actor = MagicMock() # replace with your actor

Expand Down Expand Up @@ -136,7 +136,7 @@ async def run():
async with Dispatcher(
microgrid_id=microgrid_id,
server_url=url,
auth_key=key,
key=key,
) as dispatcher:
events_receiver = dispatcher.new_lifecycle_events_receiver("DISPATCH_TYPE")

Expand Down Expand Up @@ -173,7 +173,7 @@ async def run():
async with Dispatcher(
microgrid_id=microgrid_id,
server_url=url,
auth_key=key,
key=key,
) as dispatcher:
# Create a new dispatch
new_dispatch = await dispatcher.client.create(
Expand Down Expand Up @@ -217,8 +217,8 @@ def __init__(
Args:
microgrid_id: The microgrid id.
server_url: The URL of the dispatch service.
key: The key to access the service, deprecated, use `auth_key` instead.
auth_key: The authentication key to access the service.
key: The key to access the service.
auth_key: Deprecated, use `key` instead.
sign_secret: The secret to sign the requests, optional
call_timeout: The timeout for API calls.
stream_timeout: The timeout for streaming API calls.
Expand All @@ -230,25 +230,23 @@ def __init__(

if key is not None and auth_key is not None:
raise ValueError(
"Both 'key' and 'auth_key' are provided, please use only 'auth_key'."
"Both 'key' and 'auth_key' are provided, please use only 'key'."
)

if key is None and auth_key is None:
raise ValueError(
"'auth_key' must be provided to access the dispatch service."
)
raise ValueError("'key' must be provided to access the dispatch service.")

if key is not None:
auth_key = key
if auth_key is not None:
key = auth_key
warnings.warn(
"'key' is deprecated, use 'auth_key' instead.",
"'auth_key' is deprecated, use 'key' instead.",
DeprecationWarning,
stacklevel=2,
)

self._client = DispatchApiClient(
server_url=server_url,
auth_key=auth_key,
key=key,
sign_secret=sign_secret,
call_timeout=call_timeout,
stream_timeout=stream_timeout,
Expand Down
Loading