File tree Expand file tree Collapse file tree
without_service_definition Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11"""
2- This file demonstrates how to define operation handlers by using a "shorthand" style in
3- which you implement the `start` method only. WorkflowRunOperationHandler implements
4- `cancel` for you automatically, but apart from that, the other operation methods
5- (`fetch_info`, `fetch_result`, and `cancel` for SyncOperationHandler) are all
6- automatically created with "raise NotImplementedError" implementations.
7-
8- See hello_nexus/basic/handler/service_handler_with_operation_handler_classes.py for the
9- alternative "fully manual" style where you implement an OperationHandler class directly.
2+ This file demonstrates how to implement a Nexus service.
103"""
114
125from __future__ import annotations
@@ -55,10 +48,6 @@ async def my_workflow_run_operation(
5548 # that unlike the workflow run operation above, in this case the `start` method
5649 # returns the final operation result.
5750 #
58- # Here it is implemented using SyncOperationHandler.from_callable.
59- # See service_handler_with_operation_handler_classes.py for an alternative style
60- # involving subclassing SyncOperationHandler and overriding the start method.
61- #
6251 # Sync operations are free to make arbitrary network calls, or perform CPU-bound
6352 # computations. Total execution duration must not exceed 10s.
6453 @sync_operation
Original file line number Diff line number Diff line change 33from hello_nexus .basic .service import MyInput , MyOutput
44
55
6+ # This is the workflow that is started by the `my_workflow_run_operation` nexus operation.
67@workflow .defn
78class WorkflowStartedByNexusOperation :
8- """
9- This is the workflow that is started by the `my_workflow_run_operation` nexus operation.
10- """
11-
129 @workflow .run
1310 async def run (self , input : MyInput ) -> MyOutput :
1411 return MyOutput (message = f"Hello { input .name } from workflow run operation!" )
Original file line number Diff line number Diff line change @@ -40,10 +40,9 @@ async def run(self, message: str) -> str:
4040@service_handler
4141class MyNexusService :
4242 # Here we implement a Nexus operation backed by a Temporal workflow. The start
43- # method must use TemporalOperationContext.start_workflow to start the workflow,
44- # which returns a WorkflowOperationToken. (Temporal server will then take care of
45- # delivering the workflow result to the caller, using the Nexus RPC callback
46- # mechanism).
43+ # method must use nexus.start_workflow to start the workflow. (Temporal server will
44+ # then take care of delivering the workflow result to the caller, using the Nexus
45+ # RPC callback mechanism).
4746 @workflow_run_operation
4847 async def my_workflow_run_operation (
4948 self , ctx : StartOperationContext , name : str
You can’t perform that action at this time.
0 commit comments