-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathclient.py
More file actions
41 lines (32 loc) · 1.56 KB
/
client.py
File metadata and controls
41 lines (32 loc) · 1.56 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
34
35
36
37
38
39
40
41
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import logging
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,
default_version: Optional[str] = None,
log_handler: Optional[logging.Handler] = None,
log_formatter: Optional[logging.Formatter] = None):
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,
log_handler=log_handler,
log_formatter=log_formatter,
interceptors=interceptors,
default_version=default_version)