Skip to content

Add Temporal Nexus Operation Handler#2842

Open
Quinn-With-Two-Ns wants to merge 6 commits intotemporalio:masterfrom
Quinn-With-Two-Ns:temporal-nexus-operation-handler
Open

Add Temporal Nexus Operation Handler#2842
Quinn-With-Two-Ns wants to merge 6 commits intotemporalio:masterfrom
Quinn-With-Two-Ns:temporal-nexus-operation-handler

Conversation

@Quinn-With-Two-Ns
Copy link
Copy Markdown
Contributor

@Quinn-With-Two-Ns Quinn-With-Two-Ns commented Apr 14, 2026

Add TemporalOperationHandler for generic Nexus operations

Summary

  • Adds TemporalOperationHandler, a generic OperationHandler implementation that maps Nexus operations to Temporal workflows via a composable StartFunction
  • Adds TemporalNexusClient for starting workflows (typed and untyped) from within Nexus operation handlers
  • Supports subclassing TemporalOperationHandler to customize cancel behavior by overriding cancelWorkflowRun
  • Extracts shared workflow start logic into NexusStartWorkflowHelper, reused by both WorkflowRunOperation and the new handler

Test plan

  • GenericHandlerTypedStartWorkflowTest — typed workflow with return value
  • GenericHandlerTypedProcTest — typed void workflow
  • GenericHandlerUntypedStartWorkflowTest — untyped workflow start
  • GenericHandlerSyncResultTest — synchronous result path
  • GenericHandlerCancelTest — cancel with default and custom behavior

Note

Medium Risk
Adds new Nexus/Temporal integration surface area and changes operation-token parsing/validation used for cancel dispatch; regressions could break async operation cancellation or link attachment, though changes are scoped and covered by new tests.

Overview
Adds a new experimental TemporalOperationHandler API for implementing generic Nexus OperationHandlers backed by Temporal, supporting both synchronous results (TemporalOperationResult.sync) and async workflow-start results via operation tokens.

Introduces TemporalNexusClient (+ impl) to start typed/untyped workflows (0–5 args, returning or void) from within Nexus handlers, and routes all workflow-starts through a new shared NexusStartWorkflowHelper that also attaches workflow links to the OperationContext.

Generalizes operation token handling by renaming WorkflowRunOperationToken to OperationToken, adding OperationTokenUtil.loadOperationToken for type-agnostic parsing (used for cancel dispatch), and updating WorkflowRunOperationImpl plus tests (including new coverage for generic handler start/sync/cancel flows).

Reviewed by Cursor Bugbot for commit ee62ae7. Bugbot is set up for automated code reviews on this repo. Configure here.

@Quinn-With-Two-Ns Quinn-With-Two-Ns marked this pull request as ready for review April 14, 2026 22:33
@Quinn-With-Two-Ns Quinn-With-Two-Ns requested a review from a team as a code owner April 14, 2026 22:33
TestMultiArgWorkflowFunctions.TestNoArgsWorkflowProc.class,
wf -> {
wf.proc();
return null;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maciejdudko @GregoryTravis This is one issue I found with the approach, due to ambiguity in the lambda we have to return null here for workflows that don't return anything.

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit ee62ae7. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant