|
30 | 30 |
|
31 | 31 | # pylint: enable=no-name-in-module |
32 | 32 | from frequenz.channels import Receiver |
33 | | -from frequenz.client.base.grpc_streaming_helper import GrpcStreamingHelper |
34 | | -from frequenz.client.base.retry_strategy import LinearBackoff, RetryStrategy |
| 33 | +from frequenz.client.base import retry, streaming |
35 | 34 | from google.protobuf.empty_pb2 import Empty # pylint: disable=no-name-in-module |
36 | 35 |
|
37 | 36 | from ._component import ( |
@@ -68,25 +67,25 @@ def __init__( |
68 | 67 | self, |
69 | 68 | grpc_channel: grpc.aio.Channel, |
70 | 69 | target: str, |
71 | | - retry_spec: RetryStrategy = LinearBackoff(), |
| 70 | + retry_strategy: retry.Strategy = retry.LinearBackoff(), |
72 | 71 | ) -> None: |
73 | 72 | """Initialize the class instance. |
74 | 73 |
|
75 | 74 | Args: |
76 | 75 | grpc_channel: asyncio-supporting gRPC channel |
77 | 76 | target: server (host:port) to be used for asyncio-supporting gRPC |
78 | 77 | channel that the client should use to contact the API |
79 | | - retry_spec: Specs on how to retry if the connection to a streaming |
80 | | - method gets lost. |
| 78 | + retry_strategy: The retry strategy to use to reconnect when the connection |
| 79 | + to the streaming method is lost. |
81 | 80 | """ |
82 | 81 | self.target = target |
83 | 82 | """The location (as "host:port") of the microgrid API gRPC server.""" |
84 | 83 |
|
85 | 84 | self.api = MicrogridStub(grpc_channel) |
86 | 85 | """The gRPC stub for the microgrid API.""" |
87 | 86 |
|
88 | | - self._broadcasters: dict[int, GrpcStreamingHelper[Any, Any]] = {} |
89 | | - self._retry_spec = retry_spec |
| 87 | + self._broadcasters: dict[int, streaming.GrpcStreamBroadcaster[Any, Any]] = {} |
| 88 | + self._retry_strategy = retry_strategy |
90 | 89 |
|
91 | 90 | async def components(self) -> Iterable[Component]: |
92 | 91 | """Fetch all the components present in the microgrid. |
@@ -264,7 +263,7 @@ async def _new_component_data_receiver( |
264 | 263 |
|
265 | 264 | broadcaster = self._broadcasters.setdefault( |
266 | 265 | component_id, |
267 | | - GrpcStreamingHelper( |
| 266 | + streaming.GrpcStreamBroadcaster( |
268 | 267 | f"raw-component-data-{component_id}", |
269 | 268 | # We need to cast here because grpc says StreamComponentData is |
270 | 269 | # a grpc.CallIterator[PbComponentData], not a |
|
0 commit comments