-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworker.py
32 lines (26 loc) · 845 Bytes
/
worker.py
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
import asyncio
import logging
from temporalio.client import Client
from temporalio.worker import Worker
from first_temporal.activities import extractor, transformer
from first_temporal.workflow import VehicleTransactionsWorkflow
from shared import TASK_QUEUE_NAME
async def main():
"""
Worker function where logging and the client is set up to work the queue.
"""
logging.basicConfig(level=logging.INFO)
client = await Client.connect("localhost:7233")
worker = Worker(
client,
task_queue=TASK_QUEUE_NAME,
workflows=[VehicleTransactionsWorkflow],
activities=[
extractor.pull_csv,
extractor.pull_recent_purchases,
transformer.define_customers_from_purchases
],
)
await worker.run()
if __name__ == "__main__":
asyncio.run(main())