Skip to content

Commit 096947b

Browse files
committed
Respond to upstream: top-level start_workflow function
1 parent 7debab0 commit 096947b

3 files changed

Lines changed: 6 additions & 9 deletions

File tree

hello_nexus/basic/handler/service_handler.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from temporalio.nexus.handler import (
2424
WorkflowOperationToken,
2525
WorkflowRunOperationHandler,
26-
temporal_operation_context,
26+
start_workflow,
2727
)
2828

2929
from hello_nexus.basic.handler.db_client import MyDBClient
@@ -58,8 +58,7 @@ async def start(
5858
ctx: StartOperationContext, input: MyInput
5959
) -> WorkflowOperationToken[MyOutput]:
6060
# You could use self.connected_db_client here.
61-
tctx = temporal_operation_context.get()
62-
return await tctx.start_workflow(
61+
return await start_workflow(
6362
WorkflowStartedByNexusOperation.run,
6463
input,
6564
id=str(uuid.uuid4()),

hello_nexus/basic/handler/service_handler_with_operation_handler_classes.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class directly.
3434
)
3535
from temporalio.nexus.handler import (
3636
cancel_operation,
37-
temporal_operation_context,
37+
start_workflow,
3838
)
3939

4040
from hello_nexus.basic.handler.db_client import MyDBClient
@@ -130,8 +130,7 @@ class MyWorkflowRunOperation(OperationHandler[MyInput, MyOutput]):
130130
async def start(
131131
self, ctx: StartOperationContext, input: MyInput
132132
) -> StartOperationResultAsync:
133-
tctx = temporal_operation_context.get()
134-
token = await tctx.start_workflow(
133+
token = await start_workflow(
135134
WorkflowStartedByNexusOperation.run,
136135
input,
137136
id=str(uuid.uuid4()),

hello_nexus/without_service_definition/app.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from temporalio.nexus.handler import (
2121
WorkflowOperationToken,
2222
WorkflowRunOperationHandler,
23-
temporal_operation_context,
23+
start_workflow,
2424
)
2525
from temporalio.worker import UnsandboxedWorkflowRunner, Worker
2626
from temporalio.workflow import NexusClient
@@ -57,8 +57,7 @@ def my_workflow_run_operation(
5757
async def start(
5858
ctx: StartOperationContext, name: str
5959
) -> WorkflowOperationToken[str]:
60-
tctx = temporal_operation_context.get()
61-
return await tctx.start_workflow(
60+
return await start_workflow(
6261
HandlerWorkflow.run,
6362
name,
6463
id=str(uuid.uuid4()),

0 commit comments

Comments
 (0)