Skip to content

Commit 10252a3

Browse files
shsmscamille-bouvy-frequenz
authored andcommitted
Override the BaseApiClient.connect method to also create a stub
Signed-off-by: Sahas Subramanian <[email protected]>
1 parent 97cf4d5 commit 10252a3

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/frequenz/client/electricity_trading/_client.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from frequenz.client.base.streaming import GrpcStreamBroadcaster
2424
from frequenz.client.common.pagination import Params
2525
from google.protobuf import field_mask_pb2, struct_pb2
26+
from typing_extensions import override
2627

2728
from ._types import (
2829
DeliveryArea,
@@ -166,6 +167,21 @@ def _create_stub(self) -> None:
166167
stub: Any = ElectricityTradingServiceStub(self.channel)
167168
self._stub = stub
168169

170+
@override
171+
def connect(self, server_url: str | None = None) -> None:
172+
"""Connect to the server, possibly using a new URL.
173+
174+
If the client is already connected and the URL is the same as the previous URL,
175+
this method does nothing. If you want to force a reconnection, you can call
176+
[disconnect()][frequenz.client.base.client.BaseApiClient.disconnect] first.
177+
178+
Args:
179+
server_url: The URL of the server to connect to. If not provided, the
180+
previously used URL is used.
181+
"""
182+
super().connect(server_url)
183+
self._create_stub()
184+
169185
@property
170186
def stub(self) -> ElectricityTradingServiceAsyncStub:
171187
"""

0 commit comments

Comments
 (0)