-
Notifications
You must be signed in to change notification settings - Fork 213
Stand alone operations for Nexus #2872
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
4ad65fb
60d8581
6776443
85eab3d
1e493f0
0052e5e
8f49ebc
bc30456
7cca96f
7b65472
2d75278
c479493
c773e26
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| package io.temporal.client; | ||
|
|
||
| import io.temporal.common.Experimental; | ||
| import io.temporal.common.interceptors.NexusClientCallsInterceptor.CountNexusOperationExecutionsInput; | ||
| import io.temporal.common.interceptors.NexusClientCallsInterceptor.CountNexusOperationExecutionsOutput; | ||
| import io.temporal.common.interceptors.NexusClientCallsInterceptor.ListNexusOperationExecutionsInput; | ||
| import io.temporal.common.interceptors.NexusClientCallsInterceptor.ListNexusOperationExecutionsOutput; | ||
| import io.temporal.common.interceptors.NexusClientCallsInterceptor.StartNexusOperationExecutionInput; | ||
| import io.temporal.common.interceptors.NexusClientCallsInterceptor.StartNexusOperationExecutionOutput; | ||
| import io.temporal.serviceclient.WorkflowServiceStubs; | ||
| import java.lang.reflect.Type; | ||
| import javax.annotation.Nullable; | ||
|
|
||
| /** | ||
| * Client for managing standalone Nexus operation executions. | ||
| * | ||
| * <p>Per-operation actions (describe, cancel, terminate, delete, get result) live on {@link | ||
| * NexusClientHandle}; obtain a handle via {@link #getHandle}. | ||
| */ | ||
| @Experimental | ||
| public interface NexusClient { | ||
| static NexusClient newInstance(WorkflowServiceStubs service) { | ||
| return NexusClientImpl.newInstance(service, NexusClientOperationOptions.getDefaultInstance()); | ||
| } | ||
|
|
||
| static NexusClient newInstance( | ||
| WorkflowServiceStubs service, NexusClientOperationOptions options) { | ||
| return NexusClientImpl.newInstance(service, options); | ||
| } | ||
|
|
||
| /** Returns the underlying gRPC stubs this client routes RPCs through. */ | ||
| WorkflowServiceStubs getWorkflowServiceStubs(); | ||
|
|
||
| /** | ||
| * Obtain an untyped handle to an existing operation; targets the latest run. To bind a result | ||
| * type, wrap the returned handle with {@link NexusClientHandle#fromUntyped}. | ||
| */ | ||
| UntypedNexusClientHandle getHandle(String operationId); | ||
|
|
||
| /** | ||
| * Obtain an untyped handle to an existing operation, optionally pinned to a specific run. To bind | ||
| * a result type, wrap the returned handle with {@link NexusClientHandle#fromUntyped}. | ||
| */ | ||
| UntypedNexusClientHandle getHandle(String operationId, @Nullable String runId); | ||
|
|
||
| /** Obtain a typed handle to an existing operation, bound to {@code resultClass}. */ | ||
| <R> NexusClientHandle<R> getHandle( | ||
| String operationId, @Nullable String runId, Class<R> resultClass); | ||
|
|
||
| /** | ||
| * Obtain a typed handle to an existing operation, bound to {@code resultClass}/{@code | ||
| * resultType}. Use the {@code resultType} variant when the result is a generic type whose | ||
| * parameters cannot be captured by {@link Class} alone (e.g. {@code List<String>}). | ||
| */ | ||
| <R> NexusClientHandle<R> getHandle( | ||
| String operationId, @Nullable String runId, Class<R> resultClass, @Nullable Type resultType); | ||
|
|
||
| /** Build an untyped service client targeting {@code endpoint}/{@code serviceName}. */ | ||
| UntypedNexusServiceClient newUntypedNexusServiceClient(String endpoint, String serviceName); | ||
|
|
||
| /** | ||
| * Build a typed service client for {@code serviceInterface}, targeting {@code endpoint}. The | ||
| * service name is extracted from {@code serviceInterface} via {@link | ||
| * io.nexusrpc.ServiceDefinition#fromClass}. | ||
| */ | ||
| <T> NexusServiceClient<T> newNexusServiceClient(Class<T> serviceInterface, String endpoint); | ||
|
|
||
| /** Start a new standalone Nexus operation execution. */ | ||
| StartNexusOperationExecutionOutput startNexusOperationExecution( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This method should not be on the |
||
| StartNexusOperationExecutionInput input); | ||
|
|
||
| /** List standalone Nexus operation executions matching a query. */ | ||
| ListNexusOperationExecutionsOutput listNexusOperationExecutions( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Client should not be returning interceptor types here, Look at other clients like https://github.com/temporalio/sdk-java/blob/master/temporal-sdk/src/main/java/io/temporal/client/ActivityClient.java#L37 |
||
| ListNexusOperationExecutionsInput input); | ||
|
|
||
| /** Count standalone Nexus operation executions matching a query. */ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| CountNexusOperationExecutionsOutput countNexusOperationExecutions( | ||
| CountNexusOperationExecutionsInput input); | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,45 @@ | ||||||
| package io.temporal.client; | ||||||
|
|
||||||
| import java.lang.reflect.Type; | ||||||
| import java.util.concurrent.CompletableFuture; | ||||||
| import javax.annotation.Nullable; | ||||||
|
|
||||||
| /** | ||||||
| * Typed handle for interacting with an existing standalone Nexus operation execution. Add a result | ||||||
| * type binding to an {@link UntypedNexusClientHandle} (returned by {@link | ||||||
| * NexusClient#getHandle(String)}) by calling one of the {@link #fromUntyped} factories. | ||||||
| */ | ||||||
| public interface NexusClientHandle<R> extends UntypedNexusClientHandle { | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Please keep consistent naming with other Handles like https://github.com/temporalio/sdk-java/blob/master/temporal-sdk/src/main/java/io/temporal/client/ActivityHandle.java |
||||||
|
|
||||||
| /** Wrap an {@link UntypedNexusClientHandle} as a typed handle bound to {@code resultClass}. */ | ||||||
| static <R> NexusClientHandle<R> fromUntyped( | ||||||
| UntypedNexusClientHandle handle, Class<R> resultClass) { | ||||||
| return fromUntyped(handle, resultClass, null); | ||||||
| } | ||||||
|
|
||||||
| /** | ||||||
| * Wrap an {@link UntypedNexusClientHandle} as a typed handle bound to {@code resultClass} and | ||||||
| * {@code resultType}. Pass a non-null {@code resultType} when the result is a generic type whose | ||||||
| * parameters cannot be captured by {@link Class} alone (e.g. {@code List<String>}). | ||||||
| */ | ||||||
| static <R> NexusClientHandle<R> fromUntyped( | ||||||
| UntypedNexusClientHandle handle, Class<R> resultClass, @Nullable Type resultType) { | ||||||
| return NexusClientHandleImpl.fromUntyped(handle, resultClass, resultType); | ||||||
| } | ||||||
|
|
||||||
| /** Block until the operation completes and return the typed result. */ | ||||||
| R getResult(); | ||||||
|
|
||||||
| /** Block up to {@code timeout} for the operation to complete and return the typed result. */ | ||||||
| R getResult(long timeout, java.util.concurrent.TimeUnit unit) | ||||||
| throws java.util.concurrent.TimeoutException; | ||||||
|
|
||||||
| /** Returns a future that completes with the typed result when the operation finishes. */ | ||||||
| CompletableFuture<R> getResultAsync(); | ||||||
|
|
||||||
| /** | ||||||
| * Returns a future that completes with the typed result, or completes exceptionally with a {@link | ||||||
| * java.util.concurrent.TimeoutException} if {@code timeout} elapses first. | ||||||
| */ | ||||||
| CompletableFuture<R> getResultAsync(long timeout, java.util.concurrent.TimeUnit unit); | ||||||
| } | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the methods here should have full Javadocs , see https://github.com/temporalio/sdk-java/blob/master/temporal-sdk/src/main/java/io/temporal/client/ActivityClient.java as an example