Skip to content

Commit f0d06df

Browse files
committed
Adds support for interceptors and concurrency_options arguments in the workflow engine
Signed-off-by: Albert Callarisa <[email protected]>
1 parent a7414eb commit f0d06df

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

ext/dapr-ext-workflow/dapr/ext/workflow/workflow_runtime.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515

1616
import inspect
1717
from functools import wraps
18-
from typing import Optional, TypeVar
18+
from typing import Optional, TypeVar, Union, Sequence
19+
import grpc
1920

2021
from durabletask import worker, task
2122

@@ -34,6 +35,12 @@
3435
TInput = TypeVar('TInput')
3536
TOutput = TypeVar('TOutput')
3637

38+
ClientInterceptor = Union[
39+
grpc.UnaryUnaryClientInterceptor,
40+
grpc.UnaryStreamClientInterceptor,
41+
grpc.StreamUnaryClientInterceptor,
42+
grpc.StreamStreamClientInterceptor
43+
]
3744

3845
class WorkflowRuntime:
3946
"""WorkflowRuntime is the entry point for registering workflows and activities."""
@@ -43,6 +50,10 @@ def __init__(
4350
host: Optional[str] = None,
4451
port: Optional[str] = None,
4552
logger_options: Optional[LoggerOptions] = None,
53+
interceptors: Optional[Sequence[ClientInterceptor]] = None,
54+
maximum_concurrent_activity_work_items: Optional[int] = None,
55+
maximum_concurrent_orchestration_work_items: Optional[int] = None,
56+
maximum_thread_pool_workers: Optional[int] = None,
4657
):
4758
self._logger = Logger('WorkflowRuntime', logger_options)
4859
metadata = tuple()
@@ -62,6 +73,12 @@ def __init__(
6273
secure_channel=uri.tls,
6374
log_handler=options.log_handler,
6475
log_formatter=options.log_formatter,
76+
interceptors=interceptors,
77+
concurrency_options=worker.ConcurrencyOptions(
78+
maximum_concurrent_activity_work_items=maximum_concurrent_activity_work_items,
79+
maximum_concurrent_orchestration_work_items=maximum_concurrent_orchestration_work_items,
80+
maximum_thread_pool_workers=maximum_thread_pool_workers,
81+
),
6582
)
6683

6784
def register_workflow(self, fn: Workflow, *, name: Optional[str] = None):

0 commit comments

Comments
 (0)