DurableFuture

sealed interface DurableFuture<T>

A DurableFuture allows to await an asynchronous result. Once await is called, the execution waits until the asynchronous result is available.

The result can be either a success or a failure. In case of a failure, await will throw a dev.restate.sdk.common.TerminalException.

Parameters

T

type of this future's result

Inheritors

Types

Link copied to clipboard
object Companion

Properties

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.