Awakeable

sealed interface Awakeable<T> : DurableFuture<T>

An Awakeable is a special type of DurableFuture which can be arbitrarily completed by another service, by addressing it with its id.

It can be used to let a service wait on a specific condition/result, which is fulfilled by another service or by an external system at a later point in time.

For example, you can send a Kafka record including the Awakeable.id, and then let another service consume from Kafka the responses of given external system interaction by using RestateContext.awakeableHandle.

Properties

Link copied to clipboard
abstract val id: String

The unique identifier of this Awakeable instance.

Link copied to clipboard
abstract val onAwait: SelectClause<T>

Clause for select operator.

Functions

Link copied to clipboard
abstract suspend fun await(): T

Wait for this DurableFuture to complete.

abstract suspend fun await(duration: Duration): T

Same as await but throws a dev.restate.sdk.common.TimeoutException if this DurableFuture doesn't complete before the provided timeout.

Link copied to clipboard
abstract suspend fun <R> map(transform: suspend (value: T) -> R): DurableFuture<R>

Map the success result of this DurableFuture.

abstract suspend fun <R> map(transformSuccess: suspend (value: T) -> R, transformFailure: suspend (exception: TerminalException) -> R): DurableFuture<R>

Map both the success and the failure result of this DurableFuture.

Link copied to clipboard
abstract suspend fun mapFailure(transform: suspend (exception: TerminalException) -> T): DurableFuture<T>

Map the failure result of this DurableFuture.

Link copied to clipboard
abstract suspend fun withTimeout(duration: Duration): DurableFuture<T>

Creates a DurableFuture that throws a dev.restate.sdk.common.TimeoutException if this future doesn't complete before the provided timeout.