Skip to content

Commit 573104d

Browse files
committed
Responding to PR comments
1 parent 0581e6a commit 573104d

4 files changed

Lines changed: 29 additions & 29 deletions

File tree

temporal-sdk/src/main/java/io/temporal/client/NexusServiceClient.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,21 @@
3737
* .build();
3838
*
3939
* // Operation that takes an input (Func2 overload):
40-
* String hi = client.execute(GreeterService::greet, "Ada", options);
40+
* String hi = client.execute(GreeterService::greet, options, "Ada");
4141
*
4242
* // Operation with no input (Func1 overload):
4343
* String t = client.execute(GreeterService::now, options);
4444
*
4545
* // Operation that returns Void: the same overloads work, R is just Void.
46-
* client.execute(GreeterService::log, "hello", options);
46+
* client.execute(GreeterService::log, options, "hello");
4747
*
4848
* // Get a handle instead of blocking:
49-
* NexusOperationHandle<String> handle = client.start(GreeterService::greet, "Ada", options);
49+
* NexusOperationHandle<String> handle = client.start(GreeterService::greet, options, "Ada");
5050
* String result = handle.getResult();
5151
*
5252
* // Run asynchronously:
5353
* CompletableFuture<String> future =
54-
* client.executeAsync(GreeterService::greet, "Ada", options);
54+
* client.executeAsync(GreeterService::greet, options, "Ada");
5555
* }</pre>
5656
*
5757
* @param <T> the Nexus service interface this client is bound to
@@ -65,35 +65,35 @@ public interface NexusServiceClient<T> extends UntypedNexusServiceClient {
6565
* Executes an operation synchronously with per-call options.
6666
*
6767
* @param operation a method reference on {@code T} identifying the operation
68-
* @param input the operation input
6968
* @param options per-call options controlling timeouts, search attributes, etc.
69+
* @param input the operation input
7070
* @return the operation result
7171
* @throws NexusOperationException if the operation failed, timed out, or was cancelled
7272
*/
73-
<U, R> R execute(Functions.Func2<T, U, R> operation, U input, StartNexusOperationOptions options);
73+
<U, R> R execute(Functions.Func2<T, U, R> operation, StartNexusOperationOptions options, U input);
7474

7575
/**
7676
* Starts an operation with per-call options and returns a typed handle.
7777
*
7878
* @param operation a method reference on {@code T} identifying the operation
79-
* @param input the operation input
8079
* @param options per-call options controlling timeouts, search attributes, etc.
80+
* @param input the operation input
8181
* @return a typed handle bound to the started operation
8282
*/
8383
<U, R> NexusOperationHandle<R> start(
84-
Functions.Func2<T, U, R> operation, U input, StartNexusOperationOptions options);
84+
Functions.Func2<T, U, R> operation, StartNexusOperationOptions options, U input);
8585

8686
/**
87-
* Async variant of {@link #execute(Functions.Func2, Object, StartNexusOperationOptions)}. Returns
87+
* Async variant of {@link #execute(Functions.Func2, StartNexusOperationOptions, Object)}. Returns
8888
* a {@link CompletableFuture} that completes with the typed result, or completes exceptionally if
8989
* the operation fails.
9090
*
9191
* @param operation a method reference on {@code T} identifying the operation
92-
* @param input the operation input
9392
* @param options per-call options controlling timeouts, search attributes, etc.
93+
* @param input the operation input
9494
*/
9595
<U, R> CompletableFuture<R> executeAsync(
96-
Functions.Func2<T, U, R> operation, U input, StartNexusOperationOptions options);
96+
Functions.Func2<T, U, R> operation, StartNexusOperationOptions options, U input);
9797

9898
/**
9999
* Executes a no-input operation synchronously with per-call options. Use this overload for Nexus

temporal-sdk/src/main/java/io/temporal/client/NexusServiceClientImpl.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,21 @@ private NexusServiceClientImpl(
4848

4949
@Override
5050
public <U, R> NexusOperationHandle<R> start(
51-
Functions.Func2<T, U, R> operation, U input, StartNexusOperationOptions options) {
51+
Functions.Func2<T, U, R> operation, StartNexusOperationOptions options, U input) {
5252
Method method = MethodExtractor.extract(serviceInterface, operation);
5353
return startResolved(method, input, options);
5454
}
5555

5656
@Override
5757
public <U, R> R execute(
58-
Functions.Func2<T, U, R> operation, U input, StartNexusOperationOptions options) {
59-
return start(operation, input, options).getResult();
58+
Functions.Func2<T, U, R> operation, StartNexusOperationOptions options, U input) {
59+
return start(operation, options, input).getResult();
6060
}
6161

6262
@Override
6363
public <U, R> CompletableFuture<R> executeAsync(
64-
Functions.Func2<T, U, R> operation, U input, StartNexusOperationOptions options) {
65-
return start(operation, input, options).getResultAsync();
64+
Functions.Func2<T, U, R> operation, StartNexusOperationOptions options, U input) {
65+
return start(operation, options, input).getResultAsync();
6666
}
6767

6868
@Override

temporal-sdk/src/test/java/io/temporal/client/nexus/NexusAsyncApiTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public void serviceClientExecuteAsyncReturnsResult() throws Exception {
5656
String result =
5757
buildServiceClient()
5858
.executeAsync(
59-
TestNexusServices.TestNexusService1::operation, "hello", newOptionsWithId())
59+
TestNexusServices.TestNexusService1::operation, newOptionsWithId(), "hello")
6060
.get();
6161

6262
Assert.assertEquals("echo:hello", result);
@@ -72,7 +72,7 @@ public void serviceClientExecuteAsyncWithOptionsReturnsResult() throws Exception
7272

7373
String result =
7474
buildServiceClient()
75-
.executeAsync(TestNexusServices.TestNexusService1::operation, "world", options)
75+
.executeAsync(TestNexusServices.TestNexusService1::operation, options, "world")
7676
.get();
7777

7878
Assert.assertEquals("echo:world", result);
@@ -84,7 +84,7 @@ public void serviceClientExecuteAsyncWithOptionsReturnsResult() throws Exception
8484
public void typedHandleGetResultAsyncReturnsResult() throws Exception {
8585
NexusOperationHandle<String> handle =
8686
buildServiceClient()
87-
.start(TestNexusServices.TestNexusService1::operation, "typed", newOptionsWithId());
87+
.start(TestNexusServices.TestNexusService1::operation, newOptionsWithId(), "typed");
8888

8989
String result = handle.getResultAsync().get();
9090

@@ -95,7 +95,7 @@ public void typedHandleGetResultAsyncReturnsResult() throws Exception {
9595
public void typedHandleGetResultAsyncWithTimeoutReturnsResult() throws Exception {
9696
NexusOperationHandle<String> handle =
9797
buildServiceClient()
98-
.start(TestNexusServices.TestNexusService1::operation, "typed-tm", newOptionsWithId());
98+
.start(TestNexusServices.TestNexusService1::operation, newOptionsWithId(), "typed-tm");
9999

100100
// The 60s argument here exists to satisfy the API signature being exercised; the test rule's
101101
// global timeout will fail the test long before this value matters.
@@ -150,8 +150,8 @@ public void executeAsyncPropagatesOperationFailure() throws Exception {
150150
buildServiceClient()
151151
.executeAsync(
152152
TestNexusServices.TestNexusService1::operation,
153-
EchoNexusServiceImpl.FAIL_PREFIX + "boom",
154-
newOptionsWithId());
153+
newOptionsWithId(),
154+
EchoNexusServiceImpl.FAIL_PREFIX + "boom");
155155

156156
try {
157157
future.get();

temporal-sdk/src/test/java/io/temporal/client/nexus/NexusServiceClientTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public void executeReturnsTypedResult() {
5454
buildServiceClient(testWorkflowRule.getNexusEndpoint());
5555

5656
String result =
57-
client.execute(TestNexusServices.TestNexusService1::operation, "hello", newOptionsWithId());
57+
client.execute(TestNexusServices.TestNexusService1::operation, newOptionsWithId(), "hello");
5858

5959
Assert.assertEquals("echo:hello", result);
6060
}
@@ -65,15 +65,15 @@ public void startReturnsTypedHandleAndPollsResult() {
6565
buildServiceClient(testWorkflowRule.getNexusEndpoint());
6666

6767
NexusOperationHandle<String> handle =
68-
client.start(TestNexusServices.TestNexusService1::operation, "world", newOptionsWithId());
68+
client.start(TestNexusServices.TestNexusService1::operation, newOptionsWithId(), "world");
6969

7070
Assert.assertNotNull(handle.getNexusOperationId());
7171
Assert.assertEquals("echo:world", handle.getResult());
7272
}
7373

7474
@Test
7575
public void executeWithOptionsReturnsResult() {
76-
// Covers the 3-arg execute(op, input, options) overload — exercises a non-default
76+
// Covers the 3-arg execute(op, options, input) overload — exercises a non-default
7777
// scheduleToCloseTimeout in addition to the required id.
7878
StartNexusOperationOptions options =
7979
StartNexusOperationOptions.newBuilder()
@@ -83,7 +83,7 @@ public void executeWithOptionsReturnsResult() {
8383

8484
String result =
8585
buildServiceClient(testWorkflowRule.getNexusEndpoint())
86-
.execute(TestNexusServices.TestNexusService1::operation, "with-opts", options);
86+
.execute(TestNexusServices.TestNexusService1::operation, options, "with-opts");
8787

8888
Assert.assertEquals("echo:with-opts", result);
8989
}
@@ -99,7 +99,7 @@ public void startWithExplicitIdHonoursId() {
9999

100100
NexusOperationHandle<String> handle =
101101
buildServiceClient(testWorkflowRule.getNexusEndpoint())
102-
.start(TestNexusServices.TestNexusService1::operation, "id-test", options);
102+
.start(TestNexusServices.TestNexusService1::operation, options, "id-test");
103103

104104
Assert.assertEquals(
105105
"explicit ID supplied via StartNexusOperationOptions.setId must round-trip on the handle",
@@ -120,7 +120,7 @@ public void clientSummaryReachesServer() {
120120
.setSummary("per-call-summary")
121121
.build();
122122
NexusOperationHandle<String> handle =
123-
client.start(TestNexusServices.TestNexusService1::operation, "world", startOptions);
123+
client.start(TestNexusServices.TestNexusService1::operation, startOptions, "world");
124124

125125
// Describe round-trips the operation through the server, proving the summary was actually
126126
// persisted on the server-side record rather than just forwarded through the local interceptor
@@ -161,7 +161,7 @@ public void executeWithVoidReturnCompletes() {
161161

162162
Void result =
163163
client.execute(
164-
TestNexusServices.TestNexusServiceVoidReturn::operation, "ignored", newOptionsWithId());
164+
TestNexusServices.TestNexusServiceVoidReturn::operation, newOptionsWithId(), "ignored");
165165

166166
Assert.assertNull(result);
167167
Assert.assertEquals(

0 commit comments

Comments
 (0)