forked from microsoft/durabletask-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.py
More file actions
33 lines (25 loc) · 1.24 KB
/
client.py
File metadata and controls
33 lines (25 loc) · 1.24 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
32
33
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
from typing import Optional
from azure.core.credentials import TokenCredential
from durabletask.azuremanaged.internal.durabletask_grpc_interceptor import (
DTSDefaultClientInterceptorImpl,
)
from durabletask.client import TaskHubGrpcClient
# Client class used for Durable Task Scheduler (DTS)
class DurableTaskSchedulerClient(TaskHubGrpcClient):
def __init__(self, *,
host_address: str,
taskhub: str,
token_credential: Optional[TokenCredential],
secure_channel: bool = True):
if not taskhub:
raise ValueError("Taskhub value cannot be empty. Please provide a value for your taskhub")
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)