-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathworker.py
More file actions
39 lines (31 loc) · 956 Bytes
/
worker.py
File metadata and controls
39 lines (31 loc) · 956 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
36
37
38
39
"""Run the expense audit worker against a local Temporal dev server."""
import asyncio
import logging
from temporalio.client import Client
from temporalio.worker import Worker
from activities import (
fetch_transactions,
review_large_payments,
review_recurring_payments,
)
from workflows import ExpenseAuditWorkflow
TASK_QUEUE = "expense-audit"
TARGET = "localhost:7233"
NAMESPACE = "default"
async def main() -> None:
logging.basicConfig(level=logging.INFO)
client = await Client.connect(TARGET, namespace=NAMESPACE)
worker = Worker(
client,
task_queue=TASK_QUEUE,
workflows=[ExpenseAuditWorkflow],
activities=[
fetch_transactions,
review_recurring_payments,
review_large_payments,
],
)
print(f"Worker up on {TARGET} / {NAMESPACE} / {TASK_QUEUE}. Ctrl-C to stop.")
await worker.run()
if __name__ == "__main__":
asyncio.run(main())