Skip to content

Commit 59240e6

Browse files
Add default Serde factory provider
1 parent a25c70a commit 59240e6

File tree

8 files changed

+332
-223
lines changed

8 files changed

+332
-223
lines changed

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

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,34 @@ default <T> ClientResponse<Void> resolve(
123123
}
124124
}
125125

126+
/**
127+
* Complete with success the Awakeable.
128+
*
129+
* @param clazz used to serialize the Awakeable result payload.
130+
* @param payload the result payload. MUST NOT be null.
131+
*/
132+
default <T> ClientResponse<Void> resolve(Class<T> clazz, @NonNull T payload) {
133+
return this.resolve(TypeTag.of(clazz), payload, ClientRequestOptions.DEFAULT);
134+
}
135+
136+
/** Same as {@link #resolve(Class, Object)} but async with options. */
137+
default <T> CompletableFuture<ClientResponse<Void>> resolveAsync(
138+
Class<T> clazz, @NonNull T payload, ClientRequestOptions options) {
139+
return this.resolveAsync(TypeTag.of(clazz), payload, options);
140+
}
141+
142+
/** Same as {@link #resolve(TypeTag, Object)} but async. */
143+
default <T> CompletableFuture<ClientResponse<Void>> resolveAsync(
144+
Class<T> clazz, @NonNull T payload) {
145+
return resolveAsync(TypeTag.of(clazz), payload, ClientRequestOptions.DEFAULT);
146+
}
147+
148+
/** Same as {@link #resolve(TypeTag, Object)} with options. */
149+
default <T> ClientResponse<Void> resolve(
150+
Class<T> clazz, @NonNull T payload, ClientRequestOptions options) {
151+
return resolve(TypeTag.of(clazz), payload, options);
152+
}
153+
126154
/**
127155
* Complete with success the Awakeable.
128156
*
@@ -331,7 +359,7 @@ default ClientResponse<Output<Res>> getOutput() throws IngressException {
331359
* @param baseUri uri to connect to.
332360
*/
333361
static Client connect(String baseUri) {
334-
return connect(baseUri, SerdeFactory.NOOP, ClientRequestOptions.DEFAULT);
362+
return connect(baseUri, null, null);
335363
}
336364

337365
/**
@@ -341,15 +369,14 @@ static Client connect(String baseUri) {
341369
* @param options default options to use in all the requests.
342370
*/
343371
static Client connect(String baseUri, ClientRequestOptions options) {
344-
return connect(baseUri, SerdeFactory.NOOP, options);
372+
return connect(baseUri, null, options);
345373
}
346374

347375
/**
348376
* Create a default JDK client.
349377
*
350378
* @param baseUri uri to connect to
351-
* @param serdeFactory Serde factory to use. You must provide this when the provided {@link
352-
* TypeTag} are not {@link Serde} instances. If you're just wrapping this client in a
379+
* @param serdeFactory Serde factory to use. If you're just wrapping this client in a
353380
* code-generated client, you don't need to provide this parameter.
354381
*/
355382
static Client connect(String baseUri, SerdeFactory serdeFactory) {
@@ -360,8 +387,7 @@ static Client connect(String baseUri, SerdeFactory serdeFactory) {
360387
* Create a default JDK client.
361388
*
362389
* @param baseUri uri to connect to
363-
* @param serdeFactory Serde factory to use. You must provide this when the provided {@link
364-
* TypeTag} are not {@link Serde} instances. If you're just wrapping this client in a
390+
* @param serdeFactory Serde factory to use. If you're just wrapping this client in a
365391
* code-generated client, you don't need to provide this parameter.
366392
* @param options default options to use in all the requests.
367393
*/

0 commit comments

Comments
 (0)