-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemporal_client_v8.py
More file actions
55 lines (36 loc) · 1.34 KB
/
temporal_client_v8.py
File metadata and controls
55 lines (36 loc) · 1.34 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
42
43
44
45
46
47
48
49
50
51
52
53
54
import asyncio
from temporalio.client import Client
from src.temporal_worker import queue
from src.temporal_worker_v8 import init_runtime_with_prometheus
from src.workflow.system_patch_workflow_v7 import SystemPatchWorkflow_V7
from src.workflow.types import SystemPatchWorkflowInput
SystemPatchWorkflow = SystemPatchWorkflow_V7
async def start_workflow(client, i):
workflow_id = "my-business-id-SystemPatchWorkflow_" + str(i)
workflow_handle = await client.start_workflow(
SystemPatchWorkflow.run,
SystemPatchWorkflowInput(
targetClusters=["cluster1", "cluster2", "cluster3"],
pilotHostCount=3
),
id=workflow_id,
task_queue=queue,
)
# asyncio.create_task(query_workflow(workflow_handle))
print("Workflow started with workflow_id:", workflow_handle.id)
await asyncio.sleep(3)
await workflow_handle.signal(SystemPatchWorkflow.approve_request)
print("Result:", await workflow_handle.result())
async def main():
runtime = init_runtime_with_prometheus(8085)
# Connect client
client = await Client.connect(
"localhost:7233",
runtime=runtime,
)
tasks = [asyncio.create_task(
start_workflow(client, i)
) for i in range(1,5)]
await asyncio.gather(*tasks)
if __name__ == "__main__":
asyncio.run(main())