Skip to content

Commit

Permalink
add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanos committed Oct 22, 2024
1 parent f14f563 commit c0cfc6e
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

import io.temporal.common.Experimental;
import io.temporal.workflow.Functions;

import javax.annotation.Nullable;
import java.lang.reflect.Type;
import java.util.Arrays;
import java.util.concurrent.*;
Expand Down Expand Up @@ -276,8 +278,10 @@ public static <R> Builder<R> newBuilder(String updateName, Class<R> resultClass,

private UpdateOptions<R> options;

// set by constructor (untyped) or `prepareUpdate` (typed)
private Object[] updateArgs;

// set by `prepareStart`
private Object[] workflowArgs;

private final CompletableFuture<WorkflowUpdateHandle<R>> handle;
Expand All @@ -296,8 +300,12 @@ WorkflowUpdateHandle<R> invoke(Functions.Proc workflow) {
WorkflowInvocationHandler.initAsyncInvocation(
WorkflowInvocationHandler.InvocationType.UPDATE_WITH_START, this);
try {
// invokes `prepareUpdate` via WorkflowInvocationHandler.UpdateWithStartInvocationHandler
request.apply();

// invokes `prepareStart` via WorkflowInvocationHandler.UpdateWithStartInvocationHandler
workflow.apply();

stub.updateWithStart(this, this.workflowArgs);
return this.handle.get();
} catch (InterruptedException e) {
Expand All @@ -313,6 +321,9 @@ WorkflowUpdateHandle<R> invoke(Functions.Proc workflow) {
}
}

/**
* Invoked by {@link WorkflowInvocationHandler.UpdateWithStartInvocationHandler}.
*/
void prepareUpdate(
WorkflowStub stub, String updateName, Class resultClass, Type resultType, Object[] args) {
setStub(stub);
Expand All @@ -325,6 +336,9 @@ void prepareUpdate(
.build();
}

/**
* Invoked by {@link WorkflowInvocationHandler.UpdateWithStartInvocationHandler}.
*/
void prepareStart(WorkflowStub stub, Object[] args) {
setStub(stub);
this.workflowArgs = args;
Expand Down

0 comments on commit c0cfc6e

Please sign in to comment.