-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathworker.py
More file actions
31 lines (24 loc) · 1.2 KB
/
worker.py
File metadata and controls
31 lines (24 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
from azure.core.credentials import TokenCredential
from typing import Optional
from durabletask.azuremanaged.internal.durabletask_grpc_interceptor import \
DTSDefaultClientInterceptorImpl
from durabletask.worker import TaskHubGrpcWorker
# Worker class used for Durable Task Scheduler (DTS)
class DurableTaskSchedulerWorker(TaskHubGrpcWorker):
def __init__(self, *,
host_address: str,
taskhub: str,
token_credential: Optional[TokenCredential],
secure_channel: bool = True):
if not taskhub:
raise ValueError("The taskhub value cannot be empty.")
interceptors = [DTSDefaultClientInterceptorImpl(token_credential, taskhub)]
# We pass in None for the metadata so we don't construct an additional interceptor in the parent class
# Since the parent class doesn't use anything metadata for anything else, we can set it as None
super().__init__(
host_address=host_address,
secure_channel=secure_channel,
metadata=None,
interceptors=interceptors)