77
88from hello_nexus .basic .handler .db_client import MyDBClient
99from hello_nexus .basic .handler .service_handler import MyNexusServiceHandler
10- from hello_nexus .basic .handler .service_handler_with_operation_handler_classes import (
11- MyNexusServiceHandlerUsingOperationHandlerClasses ,
12- )
1310from hello_nexus .basic .handler .workflows import WorkflowStartedByNexusOperation
1411
1512interrupt_event = asyncio .Event ()
1815TASK_QUEUE = "my-handler-task-queue"
1916
2017
21- async def main (
22- client : Optional [Client ] = None ,
23- # Change this to use the service handler defined in
24- # hello_nexus/basic/handler/service_handler_with_operation_handler_classes.py
25- use_operation_handler_classes : bool = False ,
26- ):
18+ async def main (client : Optional [Client ] = None ):
2719 logging .basicConfig (level = logging .INFO )
2820
2921 client = client or await Client .connect (
@@ -36,14 +28,6 @@ async def main(
3628 # requests. In this example we provide a database client object to the service hander.
3729 connected_db_client = MyDBClient .connect ()
3830
39- my_nexus_service_handler = (
40- MyNexusServiceHandlerUsingOperationHandlerClasses (
41- connected_db_client = connected_db_client
42- )
43- if use_operation_handler_classes
44- else MyNexusServiceHandler (connected_db_client = connected_db_client )
45- )
46-
4731 # Start the worker, passing the Nexus service handler instance, in addition to the
4832 # workflow classes that are started by your nexus operations, and any activities
4933 # needed. This Worker will poll for both workflow tasks and Nexus tasks (this example
@@ -52,7 +36,9 @@ async def main(
5236 client ,
5337 task_queue = TASK_QUEUE ,
5438 workflows = [WorkflowStartedByNexusOperation ],
55- nexus_service_handlers = [my_nexus_service_handler ],
39+ nexus_service_handlers = [
40+ MyNexusServiceHandler (connected_db_client = connected_db_client )
41+ ],
5642 ):
5743 logging .info ("Worker started, ctrl+c to exit" )
5844 await interrupt_event .wait ()
0 commit comments