-
Notifications
You must be signed in to change notification settings - Fork 121
Expand file tree
/
Copy pathhandler.py
More file actions
36 lines (29 loc) · 1.09 KB
/
Copy pathhandler.py
File metadata and controls
36 lines (29 loc) · 1.09 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
33
34
35
36
"""Temporal operation handler that starts a standalone Activity."""
from datetime import timedelta
import nexusrpc.handler
from temporalio import nexus
from nexus_standalone_activity.activity import create_greeting
from nexus_standalone_activity.service import (
GreetingInput,
GreetingOutput,
GreetingService,
)
def get_activity_id(input: GreetingInput) -> str:
return f"greeting-{input.name}"
@nexusrpc.handler.service_handler(service=GreetingService)
class GreetingServiceHandler:
@nexus.temporal_operation
async def greet(
self,
_ctx: nexus.TemporalStartOperationContext,
client: nexus.TemporalNexusClient,
input: GreetingInput,
) -> nexus.TemporalOperationResult[GreetingOutput]:
# The standalone Activity becomes the asynchronous backing execution for
# this Nexus operation. Omitting task_queue uses the Nexus Worker's queue.
return await client.start_activity(
create_greeting,
input,
id=get_activity_id(input),
start_to_close_timeout=timedelta(seconds=10),
)