Skip to content

Commit

Permalink
Add channel_defaults to the BaseApiClient example
Browse files Browse the repository at this point in the history
Signed-off-by: Leandro Lucarella <[email protected]>
  • Loading branch information
llucax committed Sep 4, 2024
1 parent 80025f9 commit 19b5e87
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/frequenz/client/base/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,24 @@ class ExampleResponseWrapper:
def __init__(self, response: ExampleResponse):
self.transformed_value = f"{response.float_value:.2f}"
# Change defaults as needed
DEFAULT_CHANNEL_OPTIONS = ChannelOptions()
class MyApiClient(BaseApiClient[ExampleAsyncStub]):
def __init__(self, server_url: str, *, connect: bool = True):
def __init__(
self,
server_url: str,
*,
connect: bool = True,
channel_defaults: ChannelOptions = DEFAULT_CHANNEL_OPTIONS,
) -> None:
super().__init__(
server_url,
# We need to type ignore here because the generated normal and
# async stubs are not type-compatible with each other.
ExampleStub, # type: ignore[arg-type]
connect=connect
connect=connect,
channel_defaults=channel_defaults,
)
self._broadcaster = GrpcStreamBroadcaster(
"stream",
Expand Down

0 comments on commit 19b5e87

Please sign in to comment.