-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix usage of IngressClient in code generated by kotlin gen
- Loading branch information
1 parent
f2bc8ba
commit 45fc2d0
Showing
2 changed files
with
52 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
sdk-api-kotlin/src/main/kotlin/dev/restate/sdk/kotlin/ingress.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright (c) 2023 - Restate Software, Inc., Restate GmbH | ||
// | ||
// This file is part of the Restate Java SDK, | ||
// which is released under the MIT license. | ||
// | ||
// You can find a copy of the license in file LICENSE in the root | ||
// directory of this repository or package, or at | ||
// https://github.com/restatedev/sdk-java/blob/main/LICENSE | ||
package dev.restate.sdk.kotlin | ||
|
||
import dev.restate.sdk.client.IngressClient | ||
import dev.restate.sdk.client.RequestOptions | ||
import dev.restate.sdk.common.Serde | ||
import dev.restate.sdk.common.Target | ||
import kotlinx.coroutines.future.await | ||
|
||
// Extension methods for the IngressClient | ||
|
||
suspend fun <Req, Res> IngressClient.callSuspend( | ||
target: Target, | ||
reqSerde: Serde<Req>, | ||
resSerde: Serde<Res>, | ||
req: Req, | ||
options: RequestOptions = RequestOptions.DEFAULT | ||
): Res { | ||
return this.callAsync(target, reqSerde, resSerde, req, options).await() | ||
} | ||
|
||
suspend fun <Req> IngressClient.sendSuspend( | ||
target: Target, | ||
reqSerde: Serde<Req>, | ||
req: Req, | ||
options: RequestOptions = RequestOptions.DEFAULT | ||
): String { | ||
return this.sendAsync(target, reqSerde, req, options).await() | ||
} | ||
|
||
suspend fun <T> IngressClient.AwakeableHandle.resolveSuspend(serde: Serde<T>, payload: T) { | ||
this.resolveAsync(serde, payload).await() | ||
} | ||
|
||
suspend fun IngressClient.AwakeableHandle.rejectSuspend(reason: String) { | ||
this.rejectAsync(reason).await() | ||
} |