blob: 770ae097510a811b8221beeda0514aef9c057281 (
about) (
plain)
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
|
from hatchet_sdk.clients.dispatcher.dispatcher import DispatcherClient
class WorkerContext:
_worker_id: str | None = None
_registered_workflow_names: list[str] = []
_labels: dict[str, str | int] = {}
def __init__(self, labels: dict[str, str | int], client: DispatcherClient):
self._labels = labels
self.client = client
def labels(self) -> dict[str, str | int]:
return self._labels
def upsert_labels(self, labels: dict[str, str | int]) -> None:
self.client.upsert_worker_labels(self._worker_id, labels)
self._labels.update(labels)
async def async_upsert_labels(self, labels: dict[str, str | int]) -> None:
await self.client.async_upsert_worker_labels(self._worker_id, labels)
self._labels.update(labels)
def id(self) -> str | None:
return self._worker_id
# def has_workflow(self, workflow_name: str):
# return workflow_name in self._registered_workflow_names
|