1010from temporalio import nexus
1111from temporalio .nexus import WorkflowRunOperationContext , workflow_run_operation
1212
13- from hello_nexus .handler .db_client import MyDBClient
1413from hello_nexus .handler .workflows import WorkflowStartedByNexusOperation
1514from hello_nexus .service import MyInput , MyNexusService , MyOutput
1615
@@ -20,11 +19,6 @@ class MyNexusServiceHandler:
2019 # You can create an __init__ method accepting what is needed by your operation
2120 # handlers to handle requests. You typically instantiate your service handler class
2221 # when starting your worker. See hello_nexus/basic/handler/worker.py.
23- def __init__ (self , connected_db_client : MyDBClient ):
24- # `connected_db_client` is intended as an example of something that might be
25- # required by your operation handlers when handling requests, but is only
26- # available at worker-start time.
27- self .connected_db_client = connected_db_client
2822
2923 # This is a nexus operation that is backed by a Temporal workflow. The start method
3024 # starts a workflow, and returns a nexus operation token. Meanwhile, the workflow
@@ -37,7 +31,6 @@ def __init__(self, connected_db_client: MyDBClient):
3731 async def my_workflow_run_operation (
3832 self , ctx : WorkflowRunOperationContext , input : MyInput
3933 ) -> nexus .WorkflowHandle [MyOutput ]:
40- # You could use self.connected_db_client here.
4134 return await ctx .start_workflow (
4235 WorkflowStartedByNexusOperation .run ,
4336 input ,
@@ -54,5 +47,4 @@ async def my_workflow_run_operation(
5447 async def my_sync_operation (
5548 self , ctx : StartOperationContext , input : MyInput
5649 ) -> MyOutput :
57- # You could use self.connected_db_client here.
5850 return MyOutput (message = f"Hello { input .name } from sync operation!" )
0 commit comments