diff --git a/hello_nexus/handler/service_handler.py b/hello_nexus/handler/service_handler.py index 1295abd1..241ae8e4 100644 --- a/hello_nexus/handler/service_handler.py +++ b/hello_nexus/handler/service_handler.py @@ -33,7 +33,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}-{uuid.uuid4()}", ) # 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..b40452b1 100644 --- a/nexus_cancel/handler/service_handler.py +++ b/nexus_cancel/handler/service_handler.py @@ -1,12 +1,15 @@ """ 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 +import uuid + import nexusrpc from temporalio import nexus @@ -23,5 +26,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}-{uuid.uuid4()}", ) diff --git a/nexus_multiple_args/handler/service_handler.py b/nexus_multiple_args/handler/service_handler.py index c2ddfb92..2998da17 100644 --- a/nexus_multiple_args/handler/service_handler.py +++ b/nexus_multiple_args/handler/service_handler.py @@ -32,7 +32,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}-{uuid.uuid4()}", )