forked from cadence-workflow/cadence-python-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.py
More file actions
37 lines (25 loc) · 875 Bytes
/
client.py
File metadata and controls
37 lines (25 loc) · 875 Bytes
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
import os
import socket
from typing import TypedDict
from cadence.api.v1.service_worker_pb2_grpc import WorkerAPIStub
from grpc.aio import Channel
class ClientOptions(TypedDict, total=False):
domain: str
identity: str
class Client:
def __init__(self, channel: Channel, options: ClientOptions) -> None:
self._channel = channel
self._worker_stub = WorkerAPIStub(channel)
self._options = options
self._identity = options["identity"] if "identity" in options else f"{os.getpid()}@{socket.gethostname()}"
@property
def domain(self) -> str:
return self._options["domain"]
@property
def identity(self) -> str:
return self._identity
@property
def worker_stub(self) -> WorkerAPIStub:
return self._worker_stub
async def close(self) -> None:
await self._channel.close()