Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions sdk-api-kotlin/src/main/kotlin/dev/restate/sdk/kotlin/ingress.kt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,18 @@ suspend fun <T : Any?> Client.InvocationHandle<T>.getOutputSuspend(
return this.getOutputAsync(options).await()
}

suspend fun <T> Client.IdempotentInvocationHandle<T>.attachSuspend(
options: RequestOptions = RequestOptions.DEFAULT
): T {
return this.attachAsync(options).await()
}

suspend fun <T> Client.IdempotentInvocationHandle<T>.getOutputSuspend(
options: RequestOptions = RequestOptions.DEFAULT
): Output<T> {
return this.getOutputAsync(options).await()
}

suspend fun <T> Client.WorkflowHandle<T>.attachSuspend(
options: RequestOptions = RequestOptions.DEFAULT
): T {
Expand Down
48 changes: 48 additions & 0 deletions sdk-common/src/main/java/dev/restate/sdk/client/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,54 @@ default Output<Res> getOutput() throws IngressException {
}
}

<Res> IdempotentInvocationHandle<Res> idempotentInvocationHandle(
Target target, String idempotencyKey, Serde<Res> resSerde);

interface IdempotentInvocationHandle<Res> {

CompletableFuture<Res> attachAsync(RequestOptions options);

default CompletableFuture<Res> attachAsync() {
return attachAsync(RequestOptions.DEFAULT);
}

default Res attach(RequestOptions options) throws IngressException {
try {
return attachAsync(options).join();
} catch (CompletionException e) {
if (e.getCause() instanceof RuntimeException) {
throw (RuntimeException) e.getCause();
}
throw new RuntimeException(e.getCause());
}
}

default Res attach() throws IngressException {
return attach(RequestOptions.DEFAULT);
}

CompletableFuture<Output<Res>> getOutputAsync(RequestOptions options);

default CompletableFuture<Output<Res>> getOutputAsync() {
return getOutputAsync(RequestOptions.DEFAULT);
}

default Output<Res> getOutput(RequestOptions options) throws IngressException {
try {
return getOutputAsync(options).join();
} catch (CompletionException e) {
if (e.getCause() instanceof RuntimeException) {
throw (RuntimeException) e.getCause();
}
throw new RuntimeException(e.getCause());
}
}

default Output<Res> getOutput() throws IngressException {
return getOutput(RequestOptions.DEFAULT);
}
}

<Res> WorkflowHandle<Res> workflowHandle(
String workflowName, String workflowId, Serde<Res> resSerde);

Expand Down
Loading