Skip to content
Merged
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
17 changes: 6 additions & 11 deletions sdk-api-kotlin/src/main/kotlin/dev/restate/sdk/kotlin/api.kt
Original file line number Diff line number Diff line change
Expand Up @@ -530,24 +530,19 @@ sealed interface DurableFuture<T> {
* Like [kotlinx.coroutines.awaitAll], but for [DurableFuture].
*
* ```
* val ctx = restateContext()
* val a1 = ctx.callAsync(GreeterGrpcKt.greetMethod, greetingRequest { name = "Francesco" })
* val a2 = ctx.callAsync(GreeterGrpcKt.greetMethod, greetingRequest { name = "Till" })
* val a1 = ctx.awakeable<String>()
* val a2 = ctx.awakeable<String>()
*
* val result = listOf(a1, a2)
* .awaitAll()
* .joinToString(separator = "-", transform = GreetingResponse::getMessage)
* .joinToString(separator = "-")
* ```
*/
suspend fun <T> Collection<DurableFuture<T>>.awaitAll(): List<T> {
return awaitAll(*toTypedArray())
}

/**
* Like [kotlinx.coroutines.awaitAll], but for [DurableFuture].
*
* ```
*/
/** @see Collection.awaitAll */
suspend fun <T> awaitAll(vararg durableFutures: DurableFuture<T>): List<T> {
if (durableFutures.isEmpty()) {
return emptyList()
Expand All @@ -563,9 +558,9 @@ suspend fun <T> awaitAll(vararg durableFutures: DurableFuture<T>): List<T> {
* Like [kotlinx.coroutines.selects.select], but for [DurableFuture]
*
* ```
* val ctx = restateContext()
* val callFuture = ctx.callAsync(GreeterGrpcKt.greetMethod, greetingRequest { name = "Francesco" })
* val callFuture = ctx.awakeable()
* val timeout = ctx.timer(10.seconds)
*
* val result = select {
* callFuture.onAwait { it.message }
* timeout.onAwait { throw TimeoutException() }
Expand Down