-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathactivities.py
More file actions
25 lines (21 loc) · 821 Bytes
/
Copy pathactivities.py
File metadata and controls
25 lines (21 loc) · 821 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
import asyncio
from typing import Optional
from temporalio import activity
from message_passing.introduction import Language
@activity.defn
async def call_greeting_service(to_language: Language) -> Optional[str]:
"""
An Activity that simulates a call to a remote greeting service.
The remote greeting service supports the full range of languages.
"""
greetings = {
Language.ARABIC: "مرحبا بالعالم",
Language.CHINESE: "你好,世界",
Language.ENGLISH: "Hello, world",
Language.FRENCH: "Bonjour, monde",
Language.HINDI: "नमस्ते दुनिया",
Language.PORTUGUESE: "Olá mundo",
Language.SPANISH: "Hola mundo",
}
await asyncio.sleep(0.2) # Simulate a network call
return greetings.get(to_language)