66
77import uuid
88
9- from nexusrpc . handler import StartOperationContext , service_handler , sync_operation
9+ import nexusrpc
1010from temporalio import nexus
11- from temporalio .nexus import WorkflowRunOperationContext , workflow_run_operation
1211
1312from hello_nexus .handler .workflows import WorkflowStartedByNexusOperation
1413from hello_nexus .service import MyInput , MyNexusService , MyOutput
1514
1615
17- @service_handler (service = MyNexusService )
16+ @nexusrpc . handler . service_handler (service = MyNexusService )
1817class MyNexusServiceHandler :
1918 # You can create an __init__ method accepting what is needed by your operation
2019 # handlers to handle requests. You typically instantiate your service handler class
@@ -27,9 +26,9 @@ class MyNexusServiceHandler:
2726 #
2827 # The token will be used by the caller if it subsequently wants to cancel the Nexus
2928 # operation.
30- @workflow_run_operation
29+ @nexus . workflow_run_operation
3130 async def my_workflow_run_operation (
32- self , ctx : WorkflowRunOperationContext , input : MyInput
31+ self , ctx : nexus . WorkflowRunOperationContext , input : MyInput
3332 ) -> nexus .WorkflowHandle [MyOutput ]:
3433 return await ctx .start_workflow (
3534 WorkflowStartedByNexusOperation .run ,
@@ -43,8 +42,8 @@ async def my_workflow_run_operation(
4342 #
4443 # Sync operations are free to make arbitrary network calls, or perform CPU-bound
4544 # computations. Total execution duration must not exceed 10s.
46- @sync_operation
45+ @nexusrpc . handler . sync_operation
4746 async def my_sync_operation (
48- self , ctx : StartOperationContext , input : MyInput
47+ self , ctx : nexusrpc . handler . StartOperationContext , input : MyInput
4948 ) -> MyOutput :
5049 return MyOutput (message = f"Hello { input .name } from sync operation!" )
0 commit comments