Skip to content

Commit bd12b17

Browse files
committed
add options to client argument and e2e test
Signed-off-by: Filinto Duran <1373693+filintod@users.noreply.github.com>
1 parent 82f0095 commit bd12b17

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

durabletask/aio/client.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ def __init__(self, *,
2727
log_handler: Optional[logging.Handler] = None,
2828
log_formatter: Optional[logging.Formatter] = None,
2929
secure_channel: bool = False,
30-
interceptors: Optional[Sequence[ClientInterceptor]] = None):
30+
interceptors: Optional[Sequence[ClientInterceptor]] = None,
31+
channel_options: Optional[Sequence[tuple[str, Any]]] = None,
32+
):
3133

3234
if interceptors is not None:
3335
interceptors = list(interceptors)
@@ -41,7 +43,8 @@ def __init__(self, *,
4143
channel = get_grpc_aio_channel(
4244
host_address=host_address,
4345
secure_channel=secure_channel,
44-
interceptors=interceptors
46+
interceptors=interceptors,
47+
options=channel_options,
4548
)
4649
self._channel = channel
4750
self._stub = stubs.TaskHubSidecarServiceStub(channel)

durabletask/client.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ def __init__(self, *,
9898
log_handler: Optional[logging.Handler] = None,
9999
log_formatter: Optional[logging.Formatter] = None,
100100
secure_channel: bool = False,
101-
interceptors: Optional[Sequence[shared.ClientInterceptor]] = None):
101+
interceptors: Optional[Sequence[shared.ClientInterceptor]] = None,
102+
channel_options: Optional[Sequence[tuple[str, Any]]] = None):
102103

103104
# If the caller provided metadata, we need to create a new interceptor for it and
104105
# add it to the list of interceptors.
@@ -114,7 +115,8 @@ def __init__(self, *,
114115
channel = shared.get_grpc_channel(
115116
host_address=host_address,
116117
secure_channel=secure_channel,
117-
interceptors=interceptors
118+
interceptors=interceptors,
119+
options=channel_options,
118120
)
119121
self._stub = stubs.TaskHubSidecarServiceStub(channel)
120122
self._logger = shared.get_logger("client", log_handler, log_formatter)

tests/durabletask/test_orchestration_e2e.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import threading
66
import time
77
from datetime import timedelta
8+
import os
89

910
import pytest
1011

@@ -28,7 +29,12 @@ def empty_orchestrator(ctx: task.OrchestrationContext, _):
2829
w.add_orchestrator(empty_orchestrator)
2930
w.start()
3031

31-
c = client.TaskHubGrpcClient()
32+
# Enable retry policy via environment and set a custom max send length option
33+
os.environ["DAPR_GRPC_RETRY_ENABLED"] = "true"
34+
os.environ["DAPR_GRPC_RETRY_MAX_ATTEMPTS"] = "3"
35+
c = client.TaskHubGrpcClient(channel_options=[
36+
("grpc.max_send_message_length", 1024 * 1024), # 1MB
37+
])
3238
id = c.schedule_new_orchestration(empty_orchestrator)
3339
state = c.wait_for_orchestration_completion(id, timeout=30)
3440

0 commit comments

Comments
 (0)