Add Temporal Nexus Operation Handler#2842
Conversation
a33ff01 to
7e61dab
Compare
7e61dab to
f2c65fc
Compare
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!
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Reviewed by Cursor Bugbot for commit de643d7. Configure here.
| new IllegalStateException( | ||
| "Only one async operation can be started per operation handler invocation. " | ||
| + "Use getWorkflowClient() for additional workflow interactions.")); | ||
| } |
There was a problem hiding this comment.
Double-start guard uses wrong error type for implementation error
Low Severity
The asyncOperationStarted guard throws a HandlerException with ErrorType.BAD_REQUEST, but this indicates a handler implementation error (calling startWorkflow twice), not a malformed client request. Using BAD_REQUEST misleads the caller into thinking their request was invalid, when the fault lies in the operation handler's logic. INTERNAL would more accurately represent a handler-side bug.
Reviewed by Cursor Bugbot for commit de643d7. Configure here.


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
New experimental handler APIs affect workflow start, cancel, and operation-token parsing on the Nexus server path; refactors are covered by tests but touch operation lifecycle behavior.
Overview
Introduces an experimental
TemporalOperationHandlerso Nexus operations can be implemented with a composable start callback,TemporalNexusClient(typed/untyped workflow starts), andTemporalOperationResultfor sync vs async completion. Cancel paths parse tokens by type and default to canceling the backing workflow, withcancelWorkflowRunoverridable on subclasses.Shared start-workflow + attach Nexus links logic moves into
NexusStartWorkflowHelper, whichWorkflowRunOperationImplnow uses instead of inlined code. Operation tokens are generalized:WorkflowRunOperationTokenbecomesOperationTokenwith explicit type;loadOperationTokensupports cancel dispatch without assuming workflow-run type.Integration tests cover typed/untyped starts, sync results, cancel, and rejecting a second async start per handler invocation.
Reviewed by Cursor Bugbot for commit d6dc34a. Bugbot is set up for automated code reviews on this repo. Configure here.