Skip to content

Commit 7d59445

Browse files
committed
Renamed Client class to DispatchApiClient
Signed-off-by: Mathias L. Baumann <[email protected]>
1 parent 31a5008 commit 7d59445

File tree

6 files changed

+16
-10
lines changed

6 files changed

+16
-10
lines changed

RELEASE_NOTES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
* `Dispatch.end_time` has been added to the `Dispatch` class, which is the time when the dispatch ended as calculated by the server. `dispatch-cli` will also print this time.
66

7+
## Upgrading
8+
9+
* Renamed `Client` class to `DispatchApiClient` for clarity.
10+
711
## Bug Fixes
812

913
* Fix that `dispatch-cli stream` would try to print an event as dispatch, causing an exception.

src/frequenz/client/dispatch/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33

44
"""Dispatch API client for Python."""
55

6-
from ._client import Client
6+
from ._client import DispatchApiClient
77

8-
__all__ = ["Client"]
8+
__all__ = ["DispatchApiClient"]

src/frequenz/client/dispatch/__main__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
JsonDictParamType,
2626
TargetComponentParamType,
2727
)
28-
from ._client import Client
28+
from ._client import DispatchApiClient
2929
from .recurrence import EndCriteria, Frequency, RecurrenceRule, Weekday
3030
from .types import Dispatch, DispatchEvent
3131

@@ -193,7 +193,7 @@ async def cli(ctx: click.Context, url: str, key: str, raw: bool) -> None:
193193

194194
click.echo(f"Using API URL: {url}", err=True)
195195

196-
ctx.obj["client"] = Client(
196+
ctx.obj["client"] = DispatchApiClient(
197197
server_url=url,
198198
key=key,
199199
connect=True,

src/frequenz/client/dispatch/_client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
DEFAULT_DISPATCH_PORT = 50051
5353

5454

55-
class Client(BaseApiClient[dispatch_pb2_grpc.MicrogridDispatchServiceStub]):
55+
class DispatchApiClient(BaseApiClient[dispatch_pb2_grpc.MicrogridDispatchServiceStub]):
5656
"""Dispatch API client."""
5757

5858
def __init__(
@@ -125,7 +125,7 @@ async def list(
125125
Example usage:
126126
127127
```python
128-
client = Client(key="key", server_url="grpc://fz-0004.frequenz.io")
128+
client = DispatchApiClient(key="key", server_url="grpc://fz-0004.frequenz.io")
129129
async for page in client.list(microgrid_id=1):
130130
for dispatch in page:
131131
print(dispatch)
@@ -207,7 +207,7 @@ def stream(self, microgrid_id: int) -> channels.Receiver[DispatchEvent]:
207207
Example usage:
208208
209209
```
210-
client = Client(key="key", server_url="grpc://fz-0004.frequenz.io")
210+
client = DispatchApiClient(key="key", server_url="grpc://fz-0004.frequenz.io")
211211
async for message in client.stream(microgrid_id=1):
212212
print(message.event, message.dispatch)
213213
```

src/frequenz/client/dispatch/test/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55

66
from typing import Any
77

8-
from .. import Client
8+
from .. import DispatchApiClient
99
from ..types import Dispatch
1010
from ._service import ALL_KEY, NONE_KEY, FakeService
1111

1212
__all__ = ["FakeClient", "to_create_params", "ALL_KEY", "NONE_KEY"]
1313

1414

15-
class FakeClient(Client):
15+
class FakeClient(DispatchApiClient):
1616
"""Fake client for testing.
1717
1818
This client uses a fake service to simulate the dispatch api.

tests/test_cli.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ def fake_client() -> FakeClient:
4444
@pytest.fixture(autouse=True)
4545
def mock_client(fake_client: FakeClient) -> Generator[None, None, None]:
4646
"""Fixture to mock get_client with FakeClient."""
47-
with patch("frequenz.client.dispatch.__main__.Client", return_value=fake_client):
47+
with patch(
48+
"frequenz.client.dispatch.__main__.DispatchApiClient", return_value=fake_client
49+
):
4850
yield
4951

5052

0 commit comments

Comments
 (0)