-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworkflows.py
31 lines (26 loc) · 942 Bytes
/
workflows.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
from datetime import timedelta
from temporalio import workflow
from temporalio.common import RetryPolicy
import logging
# Import our activity, passing it through the sandbox
with workflow.unsafe.imports_passed_through():
from activities import YourParams, compose_greeting, slack_notification
@workflow.defn
class SayHello:
@workflow.run
async def run(self, name: str) -> str:
return await workflow.execute_activity(
compose_greeting,
YourParams("Hello", name),
schedule_to_close_timeout=timedelta(seconds=5),
retry_policy=RetryPolicy(maximum_attempts=2)
)
@workflow.defn
class SayError:
@workflow.run
async def run(self, name: str) -> str:
return await workflow.execute_activity(
slack_notification,
YourParams("You have the following error:", name),
schedule_to_close_timeout=timedelta(seconds=5),
)