diff --git a/hello_nexus/handler/service_handler.py b/hello_nexus/handler/service_handler.py index 1295abd1..812a5c5d 100644 --- a/hello_nexus/handler/service_handler.py +++ b/hello_nexus/handler/service_handler.py @@ -4,8 +4,6 @@ from __future__ import annotations -import uuid - import nexusrpc from temporalio import nexus @@ -33,7 +31,7 @@ async def my_workflow_run_operation( return await ctx.start_workflow( WorkflowStartedByNexusOperation.run, input, - id=str(uuid.uuid4()), + id=f"hello-nexus-workflow-{input.name}", ) # This is a Nexus operation that responds synchronously to all requests. That means diff --git a/nexus_cancel/handler/service_handler.py b/nexus_cancel/handler/service_handler.py index 92868510..5d75e8a6 100644 --- a/nexus_cancel/handler/service_handler.py +++ b/nexus_cancel/handler/service_handler.py @@ -1,8 +1,9 @@ """ Nexus service handler for the cancellation sample. -The hello operation is backed by a workflow, using the Nexus request ID as the -workflow ID for idempotency across retries. +The hello operation is backed by a workflow whose ID is derived from the +operation input (name + language), giving each fan-out branch a distinct, +meaningful business ID. """ from __future__ import annotations @@ -23,5 +24,5 @@ async def hello( return await ctx.start_workflow( HelloHandlerWorkflow.run, input, - id=ctx.request_id, + id=f"hello-handler-{input.name}-{input.language.name}", ) diff --git a/nexus_multiple_args/handler/service_handler.py b/nexus_multiple_args/handler/service_handler.py index c2ddfb92..8c00ee31 100644 --- a/nexus_multiple_args/handler/service_handler.py +++ b/nexus_multiple_args/handler/service_handler.py @@ -1,7 +1,5 @@ from __future__ import annotations -import uuid - import nexusrpc from temporalio import nexus @@ -32,7 +30,7 @@ async def hello( input.name, # First argument: name input.language, # Second argument: language ], - id=str(uuid.uuid4()), + id=f"hello-multi-args-{input.name}-{input.language}", )