Skip to content

Commit

Permalink
Rename UpdateHandle to WorkflowUpdateHandle (#2204)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanos authored Sep 3, 2024
1 parent 1a054bb commit ecd26b7
Show file tree
Hide file tree
Showing 16 changed files with 50 additions and 48 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/features.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ jobs:
with:
java-repo-path: ${{github.event.pull_request.head.repo.full_name}}
version: ${{github.event.pull_request.head.ref}}
version-is-repo-ref: true
version-is-repo-ref: true
features-repo-ref: WorkflowUpdateHandle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import io.opentracing.Scope;
import io.opentracing.Span;
import io.opentracing.Tracer;
import io.temporal.client.UpdateHandle;
import io.temporal.client.WorkflowUpdateHandle;
import io.temporal.common.interceptors.WorkflowClientCallsInterceptor;
import io.temporal.common.interceptors.WorkflowClientCallsInterceptorBase;
import io.temporal.opentracing.OpenTracingOptions;
Expand Down Expand Up @@ -120,7 +120,7 @@ public <R> QueryOutput<R> query(QueryInput<R> input) {
}

@Override
public <R> UpdateHandle<R> startUpdate(StartUpdateInput<R> input) {
public <R> WorkflowUpdateHandle<R> startUpdate(StartUpdateInput<R> input) {
Span workflowStartUpdateSpan =
contextAccessor.writeSpanContextToHeader(
() ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ static <T> WorkflowStub fromTyped(T typed) {
* @return update handle that can be used to get the result of the update.
*/
@Experimental
<R> UpdateHandle<R> startUpdate(
<R> WorkflowUpdateHandle<R> startUpdate(
String updateName, WorkflowUpdateStage waitForStage, Class<R> resultClass, Object... args);

/**
Expand All @@ -118,7 +118,7 @@ <R> UpdateHandle<R> startUpdate(
* @return update handle that can be used to get the result of the update.
*/
@Experimental
<R> UpdateHandle<R> startUpdate(UpdateOptions<R> options, Object... args);
<R> WorkflowUpdateHandle<R> startUpdate(UpdateOptions<R> options, Object... args);

/**
* Get an update handle to a previously started update request. Getting an update handle does not
Expand All @@ -130,7 +130,7 @@ <R> UpdateHandle<R> startUpdate(
* @return update handle that can be used to get the result of the update.
*/
@Experimental
<R> UpdateHandle<R> getUpdateHandle(String updateId, Class<R> resultClass);
<R> WorkflowUpdateHandle<R> getUpdateHandle(String updateId, Class<R> resultClass);

/**
* Get an update handle to a previously started update request. Getting an update handle does not
Expand All @@ -144,7 +144,8 @@ <R> UpdateHandle<R> startUpdate(
* @return update handle that can be used to get the result of the update.
*/
@Experimental
<R> UpdateHandle<R> getUpdateHandle(String updateId, Class<R> resultClass, Type resultType);
<R> WorkflowUpdateHandle<R> getUpdateHandle(
String updateId, Class<R> resultClass, Type resultType);

WorkflowExecution start(Object... args);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import io.temporal.common.interceptors.Header;
import io.temporal.common.interceptors.WorkflowClientCallsInterceptor;
import io.temporal.failure.CanceledFailure;
import io.temporal.internal.client.LazyUpdateHandleImpl;
import io.temporal.internal.client.LazyWorkflowUpdateHandleImpl;
import io.temporal.serviceclient.CheckedExceptionWrapper;
import io.temporal.serviceclient.StatusUtils;
import java.lang.reflect.Type;
Expand Down Expand Up @@ -313,7 +313,7 @@ public <R> R update(String updateName, Class<R> resultClass, Object... args) {
}

@Override
public <R> UpdateHandle<R> startUpdate(
public <R> WorkflowUpdateHandle<R> startUpdate(
String updateName, WorkflowUpdateStage waitForStage, Class<R> resultClass, Object... args) {
UpdateOptions<R> options =
UpdateOptions.<R>newBuilder()
Expand All @@ -327,7 +327,7 @@ public <R> UpdateHandle<R> startUpdate(
}

@Override
public <R> UpdateHandle<R> startUpdate(UpdateOptions<R> options, Object... args) {
public <R> WorkflowUpdateHandle<R> startUpdate(UpdateOptions<R> options, Object... args) {
checkStarted();
options.validate();
WorkflowExecution targetExecution = execution.get();
Expand All @@ -353,8 +353,8 @@ public <R> UpdateHandle<R> startUpdate(UpdateOptions<R> options, Object... args)
}

@Override
public <R> UpdateHandle<R> getUpdateHandle(String updateId, Class<R> resultClass) {
return new LazyUpdateHandleImpl<>(
public <R> WorkflowUpdateHandle<R> getUpdateHandle(String updateId, Class<R> resultClass) {
return new LazyWorkflowUpdateHandleImpl<>(
workflowClientInvoker,
workflowType.orElse(null),
"",
Expand All @@ -365,9 +365,9 @@ public <R> UpdateHandle<R> getUpdateHandle(String updateId, Class<R> resultClass
}

@Override
public <R> UpdateHandle<R> getUpdateHandle(
public <R> WorkflowUpdateHandle<R> getUpdateHandle(
String updateId, Class<R> resultClass, Type resultType) {
return new LazyUpdateHandleImpl<>(
return new LazyWorkflowUpdateHandleImpl<>(
workflowClientInvoker,
workflowType.orElse(null),
"",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
import java.util.concurrent.TimeUnit;

/**
* UpdateHandle is a handle to an update workflow execution request that can be used to get the
* status of that update request.
* WorkflowUpdateHandle is a handle to an update workflow execution request that can be used to get
* the status of that update request.
*/
@Experimental
public interface UpdateHandle<T> {
public interface WorkflowUpdateHandle<T> {
/**
* Gets the workflow execution this update request was sent to.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import io.temporal.api.common.v1.WorkflowExecution;
import io.temporal.api.enums.v1.WorkflowExecutionStatus;
import io.temporal.api.update.v1.WaitPolicy;
import io.temporal.client.UpdateHandle;
import io.temporal.client.WorkflowOptions;
import io.temporal.client.WorkflowUpdateHandle;
import io.temporal.common.Experimental;
import java.lang.reflect.Type;
import java.util.Optional;
Expand Down Expand Up @@ -78,7 +78,7 @@ public interface WorkflowClientCallsInterceptor {
<R> QueryOutput<R> query(QueryInput<R> input);

@Experimental
<R> UpdateHandle<R> startUpdate(StartUpdateInput<R> input);
<R> WorkflowUpdateHandle<R> startUpdate(StartUpdateInput<R> input);

@Experimental
<R> PollWorkflowUpdateOutput<R> pollWorkflowUpdate(PollWorkflowUpdateInput<R> input);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

package io.temporal.common.interceptors;

import io.temporal.client.UpdateHandle;
import io.temporal.client.WorkflowUpdateHandle;
import java.util.concurrent.TimeoutException;

/** Convenience base class for {@link WorkflowClientCallsInterceptor} implementations. */
Expand Down Expand Up @@ -63,7 +63,7 @@ public <R> QueryOutput<R> query(QueryInput<R> input) {
}

@Override
public <R> UpdateHandle<R> startUpdate(StartUpdateInput<R> input) {
public <R> WorkflowUpdateHandle<R> startUpdate(StartUpdateInput<R> input) {
return next.startUpdate(input);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@
package io.temporal.internal.client;

import io.temporal.api.common.v1.WorkflowExecution;
import io.temporal.client.UpdateHandle;
import io.temporal.client.WorkflowUpdateHandle;
import io.temporal.common.Experimental;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;

@Experimental
public final class CompletedUpdateHandleImpl<T> implements UpdateHandle<T> {
public final class CompletedWorkflowUpdateHandleImpl<T> implements WorkflowUpdateHandle<T> {

private final String id;
private final WorkflowExecution execution;
private final T result;

public CompletedUpdateHandleImpl(String id, WorkflowExecution execution, T result) {
public CompletedWorkflowUpdateHandleImpl(String id, WorkflowExecution execution, T result) {
this.id = id;
this.execution = execution;
this.result = result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
import io.grpc.Status;
import io.grpc.StatusRuntimeException;
import io.temporal.api.common.v1.WorkflowExecution;
import io.temporal.client.UpdateHandle;
import io.temporal.client.WorkflowException;
import io.temporal.client.WorkflowServiceException;
import io.temporal.client.WorkflowUpdateHandle;
import io.temporal.common.Experimental;
import io.temporal.common.interceptors.WorkflowClientCallsInterceptor;
import io.temporal.serviceclient.CheckedExceptionWrapper;
Expand All @@ -36,7 +36,7 @@
import java.util.concurrent.TimeoutException;

@Experimental
public final class LazyUpdateHandleImpl<T> implements UpdateHandle<T> {
public final class LazyWorkflowUpdateHandleImpl<T> implements WorkflowUpdateHandle<T> {

private final WorkflowClientCallsInterceptor workflowClientInvoker;
private final String workflowType;
Expand All @@ -47,7 +47,7 @@ public final class LazyUpdateHandleImpl<T> implements UpdateHandle<T> {
private final Type resultType;
private WorkflowClientCallsInterceptor.PollWorkflowUpdateOutput<T> waitCompletedPollCall;

public LazyUpdateHandleImpl(
public LazyWorkflowUpdateHandleImpl(
WorkflowClientCallsInterceptor workflowClientInvoker,
String workflowType,
String updateName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ public <R> QueryOutput<R> query(QueryInput<R> input) {
}

@Override
public <R> UpdateHandle<R> startUpdate(StartUpdateInput<R> input) {
public <R> WorkflowUpdateHandle<R> startUpdate(StartUpdateInput<R> input) {
DataConverter dataConverterWithWorkflowContext =
clientOptions
.getDataConverter()
Expand Down Expand Up @@ -366,7 +366,7 @@ public <R> UpdateHandle<R> startUpdate(StartUpdateInput<R> input) {
input.getResultClass(),
input.getResultType(),
dataConverterWithWorkflowContext);
return new CompletedUpdateHandleImpl<>(
return new CompletedWorkflowUpdateHandleImpl<>(
result.getUpdateRef().getUpdateId(),
result.getUpdateRef().getWorkflowExecution(),
resultValue);
Expand All @@ -383,8 +383,8 @@ public <R> UpdateHandle<R> startUpdate(StartUpdateInput<R> input) {
+ result.getOutcome().getValueCase());
}
} else {
LazyUpdateHandleImpl<R> handle =
new LazyUpdateHandleImpl<>(
LazyWorkflowUpdateHandleImpl<R> handle =
new LazyWorkflowUpdateHandleImpl<>(
this,
input.getWorkflowType().orElse(null),
input.getUpdateName(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void pollUpdateNonExistentWorkflow() throws ExecutionException, Interrupt
WorkflowStub workflowStub =
testWorkflowRule.getWorkflowClient().newUntypedWorkflowStub("non-existing-id");
// Getting the update handle to a nonexistent workflow is fine
UpdateHandle<String> handle = workflowStub.getUpdateHandle("update-id", String.class);
WorkflowUpdateHandle<String> handle = workflowStub.getUpdateHandle("update-id", String.class);
assertThrows(Exception.class, () -> handle.getResultAsync().get());
}

Expand Down Expand Up @@ -124,7 +124,7 @@ public void updateWorkflowDuplicateId() throws ExecutionException, InterruptedEx
String updateId = "update-id";

// Try to get the result of an invalid update
UpdateHandle<String> handle = workflowStub.getUpdateHandle(updateId, String.class);
WorkflowUpdateHandle<String> handle = workflowStub.getUpdateHandle(updateId, String.class);
assertThrows(Exception.class, () -> handle.getResultAsync().get());

assertEquals(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void closeWorkflowWhileUpdateIsRunning() throws ExecutionException, Inter
workflowStub.start();
SDKTestWorkflowRule.waitForOKQuery(workflowStub);
// Send an update that is accepted, but will not complete.
UpdateHandle<String> handle =
WorkflowUpdateHandle<String> handle =
workflowStub.startUpdate(
"update", WorkflowUpdateStage.ACCEPTED, String.class, 10_000, "some-value");

Expand All @@ -78,7 +78,7 @@ public void LongRunningWorkflowUpdateId() throws ExecutionException, Interrupted

workflowStub.start();
SDKTestWorkflowRule.waitForOKQuery(workflowStub);
UpdateHandle<String> handle =
WorkflowUpdateHandle<String> handle =
workflowStub.startUpdate(
"update", WorkflowUpdateStage.ACCEPTED, String.class, 65_000, "some-value");

Expand All @@ -99,7 +99,7 @@ public void WorkflowUpdateGetResultTimeout() throws ExecutionException, Interrup
workflowStub.start();
SDKTestWorkflowRule.waitForOKQuery(workflowStub);

UpdateHandle<String> handle =
WorkflowUpdateHandle<String> handle =
workflowStub.startUpdate(
"update", WorkflowUpdateStage.ACCEPTED, String.class, 10_000, "some-value");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void isEveryHandlerFinished() throws ExecutionException, InterruptedExcep
WorkflowExecution execution = WorkflowClient.start(workflow::execute);

WorkflowStub untypedStub = workflowClient.newUntypedWorkflowStub(execution.getWorkflowId());
List<UpdateHandle<String>> updateHandles = new ArrayList<>();
List<WorkflowUpdateHandle<String>> updateHandles = new ArrayList<>();
// Send a bunch of update requests
for (int i = 0; i < 5; i++) {
updateHandles.add(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ public void testUpdateInfo() throws ExecutionException, InterruptedException {
.setUpdateName("update")
.setWaitForStage(WorkflowUpdateStage.COMPLETED);

UpdateHandle handle1 =
WorkflowUpdateHandle handle1 =
stub.startUpdate(updateOptionsBuilder.setUpdateId("update id 1").build(), 0, "");
assertEquals("update:update id 1", handle1.getResultAsync().get());

UpdateHandle handle2 =
WorkflowUpdateHandle handle2 =
stub.startUpdate(updateOptionsBuilder.setUpdateId("update id 2").build(), 0, "");
assertEquals("update:update id 2", handle2.getResultAsync().get());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import io.temporal.common.interceptors.WorkflowClientCallsInterceptorBase;
import io.temporal.common.interceptors.WorkflowClientInterceptorBase;
import io.temporal.failure.ApplicationFailure;
import io.temporal.internal.client.CompletedUpdateHandleImpl;
import io.temporal.internal.client.CompletedWorkflowUpdateHandleImpl;
import io.temporal.testing.internal.SDKTestOptions;
import io.temporal.testing.internal.SDKTestWorkflowRule;
import io.temporal.worker.WorkerOptions;
Expand Down Expand Up @@ -113,9 +113,9 @@ public WorkflowClientCallsInterceptor workflowClientCallsInterceptor(
WorkflowClientCallsInterceptor next) {
return new WorkflowClientCallsInterceptorBase(next) {
@Override
public <R> UpdateHandle<R> startUpdate(StartUpdateInput<R> input) {
public <R> WorkflowUpdateHandle<R> startUpdate(StartUpdateInput<R> input) {
super.startUpdate(input);
return new CompletedUpdateHandleImpl<>(
return new CompletedWorkflowUpdateHandleImpl<>(
"someid", input.getWorkflowExecution(), (R) "fake");
}
};
Expand Down Expand Up @@ -173,7 +173,7 @@ public void testUpdateUntyped() throws ExecutionException, InterruptedException
// send an update through the sync path
assertEquals("Execute-Hello", workflowStub.update("update", String.class, 0, "Hello"));
// send an update through the async path
UpdateHandle<String> updateRef =
WorkflowUpdateHandle<String> updateRef =
workflowStub.startUpdate("update", WorkflowUpdateStage.ACCEPTED, String.class, 0, "World");
assertEquals("Execute-World", updateRef.getResultAsync().get());
// send a bad update that will be rejected through the sync path
Expand Down Expand Up @@ -266,7 +266,7 @@ public void testUpdateHandleNotReturnedUntilCompleteWhenAsked()
Executors.newSingleThreadExecutor()
.submit(
() -> {
UpdateHandle<String> handle =
WorkflowUpdateHandle<String> handle =
workflowStub.startUpdate(
UpdateOptions.newBuilder(String.class)
.setUpdateName("update")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,23 +236,23 @@ public <R> R update(String updateName, Class<R> resultClass, Object... args) {
}

@Override
public <R> UpdateHandle<R> startUpdate(
public <R> WorkflowUpdateHandle<R> startUpdate(
String updateName, WorkflowUpdateStage waitForStage, Class<R> resultClass, Object... args) {
return next.startUpdate(updateName, waitForStage, resultClass, args);
}

@Override
public <R> UpdateHandle<R> startUpdate(UpdateOptions<R> options, Object... args) {
public <R> WorkflowUpdateHandle<R> startUpdate(UpdateOptions<R> options, Object... args) {
return next.startUpdate(options, args);
}

@Override
public <R> UpdateHandle<R> getUpdateHandle(String updateId, Class<R> resultClass) {
public <R> WorkflowUpdateHandle<R> getUpdateHandle(String updateId, Class<R> resultClass) {
return next.getUpdateHandle(updateId, resultClass);
}

@Override
public <R> UpdateHandle<R> getUpdateHandle(
public <R> WorkflowUpdateHandle<R> getUpdateHandle(
String updateId, Class<R> resultClass, Type resultType) {
return next.getUpdateHandle(updateId, resultClass, resultType);
}
Expand Down

0 comments on commit ecd26b7

Please sign in to comment.