forked from temporalio/samples-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathworkflows.py
More file actions
32 lines (27 loc) · 1.11 KB
/
workflows.py
File metadata and controls
32 lines (27 loc) · 1.11 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
from temporalio import workflow
with workflow.unsafe.imports_passed_through():
from nexus_multiple_args.service import HelloOutput
# This is the workflow that is started by the `hello` nexus operation.
# It demonstrates handling multiple arguments passed from the Nexus service.
@workflow.defn
class HelloHandlerWorkflow:
@workflow.run
async def run(self, name: str, language: str) -> HelloOutput:
"""
Handle the hello workflow with multiple arguments.
This method receives the individual arguments (name and language)
that were unpacked from the HelloInput in the service handler.
"""
if language == "en":
message = f"Hello {name} 👋"
elif language == "fr":
message = f"Bonjour {name} 👋"
elif language == "de":
message = f"Hallo {name} 👋"
elif language == "es":
message = f"¡Hola! {name} 👋"
elif language == "tr":
message = f"Merhaba {name} 👋"
else:
raise ValueError(f"Unsupported language: {language}")
return HelloOutput(message=message)