Skip to content

Commit 53f1022

Browse files
Improve suspend overloads for kotlin clients
1 parent 59240e6 commit 53f1022

File tree

2 files changed

+14
-7
lines changed
  • client-kotlin/src/main/kotlin/dev/restate/client/kotlin
  • client/src/main/java/dev/restate/client

2 files changed

+14
-7
lines changed

client-kotlin/src/main/kotlin/dev/restate/client/kotlin/ingress.kt

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import dev.restate.client.SendResponse
1515
import dev.restate.common.Output
1616
import dev.restate.common.Request
1717
import dev.restate.common.WorkflowRequest
18-
import dev.restate.serde.Serde
18+
import dev.restate.serde.TypeTag
19+
import dev.restate.serde.kotlinx.typeTag
1920
import kotlin.time.Duration
2021
import kotlin.time.toJavaDuration
2122
import kotlinx.coroutines.future.await
@@ -71,11 +72,18 @@ suspend fun <Req, Res> Client.submitSuspend(
7172
}
7273

7374
suspend fun <T : Any> Client.AwakeableHandle.resolveSuspend(
74-
serde: Serde<T>,
75+
typeTag: TypeTag<T>,
7576
payload: T,
7677
options: ClientRequestOptions = ClientRequestOptions.DEFAULT
7778
): ClientResponse<Void> {
78-
return this.resolveAsync(serde, payload, options).await()
79+
return this.resolveAsync(typeTag, payload, options).await()
80+
}
81+
82+
suspend inline fun <reified T : Any> Client.AwakeableHandle.resolveSuspend(
83+
payload: T,
84+
options: ClientRequestOptions = ClientRequestOptions.DEFAULT
85+
): ClientResponse<Void> {
86+
return this.resolveSuspend(typeTag<T>(), payload, options)
7987
}
8088

8189
suspend fun Client.AwakeableHandle.rejectSuspend(

client/src/main/java/dev/restate/client/Client.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import dev.restate.common.Request;
1313
import dev.restate.common.Target;
1414
import dev.restate.common.WorkflowRequest;
15-
import dev.restate.serde.Serde;
1615
import dev.restate.serde.SerdeFactory;
1716
import dev.restate.serde.TypeTag;
1817
import java.time.Duration;
@@ -135,19 +134,19 @@ default <T> ClientResponse<Void> resolve(Class<T> clazz, @NonNull T payload) {
135134

136135
/** Same as {@link #resolve(Class, Object)} but async with options. */
137136
default <T> CompletableFuture<ClientResponse<Void>> resolveAsync(
138-
Class<T> clazz, @NonNull T payload, ClientRequestOptions options) {
137+
Class<T> clazz, @NonNull T payload, ClientRequestOptions options) {
139138
return this.resolveAsync(TypeTag.of(clazz), payload, options);
140139
}
141140

142141
/** Same as {@link #resolve(TypeTag, Object)} but async. */
143142
default <T> CompletableFuture<ClientResponse<Void>> resolveAsync(
144-
Class<T> clazz, @NonNull T payload) {
143+
Class<T> clazz, @NonNull T payload) {
145144
return resolveAsync(TypeTag.of(clazz), payload, ClientRequestOptions.DEFAULT);
146145
}
147146

148147
/** Same as {@link #resolve(TypeTag, Object)} with options. */
149148
default <T> ClientResponse<Void> resolve(
150-
Class<T> clazz, @NonNull T payload, ClientRequestOptions options) {
149+
Class<T> clazz, @NonNull T payload, ClientRequestOptions options) {
151150
return resolve(TypeTag.of(clazz), payload, options);
152151
}
153152

0 commit comments

Comments
 (0)