Add Temporal Nexus Operation Handler#2842
Conversation
a33ff01 to
7e61dab
Compare
7e61dab to
f2c65fc
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default mode and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
Reviewed by Cursor Bugbot for commit f2c65fc. Configure here.
VegetarianOrc
left a comment
There was a problem hiding this comment.
Looks great. Couple small questions mostly for my learning!
| if (Strings.isNullOrEmpty(token.getWorkflowId())) { | ||
| throw new IllegalArgumentException("Invalid workflow run token: missing workflow ID (wid)"); | ||
| throw new IllegalArgumentException("Invalid operation token: missing workflow ID (wid)"); |
There was a problem hiding this comment.
Should this check be moved into loadWorkflowRunOperationToken?
| /** | ||
| * Returns the synchronous result value, or null if this is an async result. | ||
| * | ||
| * @return the sync result value, or null | ||
| */ | ||
| @Nullable | ||
| public R getSyncResult() { | ||
| return syncResult; | ||
| } | ||
|
|
||
| /** | ||
| * Returns the async operation token, or null if this is a sync result. | ||
| * | ||
| * @return the operation token, or null | ||
| */ | ||
| @Nullable | ||
| public String getAsyncOperationToken() { | ||
| return asyncOperationToken; | ||
| } |
There was a problem hiding this comment.
Just a style question to familiarize myself with Java a bit more: Should these throw if invoked on the wrong type of result? i.e. should getAsyncOperationToken throw if isSync == true?
|
|
||
| public WorkflowRunOperationToken(String namespace, String workflowId) { | ||
| this.type = OperationTokenType.WORKFLOW_RUN; | ||
| public OperationToken(OperationTokenType type, String namespace, String workflowId) { |
There was a problem hiding this comment.
With more types of tokens upcoming, should we favor something like static constructors for this like OperationToken.NewWorkflowRunToken() that takes the required fields for the workflow run type?
I guess this is a bit like what OperationTokenUtil provides so feel free to dismiss this!

Add TemporalOperationHandler for generic Nexus operations
Goal
Provide a new base to make it easy to expose more Temporal actions as Nexus Operations
Summary
Test plan
Note
Medium Risk
Adds new Nexus-to-Temporal dispatch APIs (start/cancel) and refactors workflow-start/link attachment logic, which could affect Nexus operation execution and cancellation paths. Behavior is guarded by new token validation and single-async-start enforcement but still touches core operation flow.
Overview
Adds an experimental
TemporalOperationHandlerthat maps Nexusstartto either a synchronous result or an async workflow-run token via a newTemporalNexusClient(typed/untypedstartWorkflowoverloads) andTemporalOperationResult.Refactors workflow-start behavior into
NexusStartWorkflowHelperso both the existingWorkflowRunOperationImpland the new client share the same request construction and workflow-link attachment logic, and enforces only one async start per handler invocation.Renames/expands operation-token handling (
WorkflowRunOperationToken->OperationToken) and updatesOperationTokenUtilto support type-agnostic token loading for cancel dispatch, with updated/added tests covering sync results, typed/untyped starts, double-start errors, and cancel behavior.Reviewed by Cursor Bugbot for commit d448f63. Bugbot is set up for automated code reviews on this repo. Configure here.