Skip to content

Commit 9ed7da0

Browse files
committed
Add channel_defaults to the BaseApiClient example
Signed-off-by: Leandro Lucarella <[email protected]>
1 parent 80025f9 commit 9ed7da0

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/frequenz/client/base/client.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,24 @@ class ExampleResponseWrapper:
7070
def __init__(self, response: ExampleResponse):
7171
self.transformed_value = f"{response.float_value:.2f}"
7272
73+
# Change defaults as needed
74+
DEFAULT_CHANNEL_OPTIONS = ChannelOptions()
75+
7376
class MyApiClient(BaseApiClient[ExampleAsyncStub]):
74-
def __init__(self, server_url: str, *, connect: bool = True):
77+
def __init__(
78+
self,
79+
server_url: str,
80+
*,
81+
connect: bool = True,
82+
channel_defaults: ChannelOptions = DEFAULT_CHANNEL_OPTIONS,
83+
) -> None:
7584
super().__init__(
7685
server_url,
7786
# We need to type ignore here because the generated normal and
7887
# async stubs are not type-compatible with each other.
7988
ExampleStub, # type: ignore[arg-type]
8089
connect=connect
90+
channel_defaults=channel_defaults,
8191
)
8292
self._broadcaster = GrpcStreamBroadcaster(
8393
"stream",

0 commit comments

Comments
 (0)