Package-level declarations

Types

Link copied to clipboard
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.

Link copied to clipboard
sealed interface AwakeableHandle

This class represents a handle to an Awakeable created in another service.

Link copied to clipboard
sealed interface CallDurableFuture<T> : DurableFuture<T>

The DurableFuture returned by a Context.call.

Link copied to clipboard
sealed interface Context

This interface exposes the Restate functionalities to Restate services. It can be used to interact with other Restate services, record non-deterministic closures, execute timers and synchronize with external systems.

Link copied to clipboard
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.

Link copied to clipboard
sealed interface DurablePromise<T>

A DurablePromise is a durable, distributed version of a Kotlin's Deferred, or more commonly of a future/promise. Restate keeps track of the DurablePromise across restarts/failures.

Link copied to clipboard
sealed interface DurablePromiseHandle<T>

This class represents a handle to a DurablePromise created in another service.

Link copied to clipboard
Link copied to clipboard
sealed interface InvocationHandle<Res>

An invocation handle, that can be used to interact with a running invocation.

Link copied to clipboard
@ApiStatus.Experimental
interface KotlinState

Interface for accessing Virtual Object/Workflow state in the reflection-based API.

Link copied to clipboard
@ApiStatus.Experimental
interface KRequest<Req, Res> : Request<Req, Res>

Kotlin-idiomatic request for invoking Restate services from within a handler.

Link copied to clipboard
@ApiStatus.Experimental
class KRequestBuilder<SVC : Any>

Builder for creating type-safe requests from within a handler.

Link copied to clipboard
Link copied to clipboard
object KtSerdes
Link copied to clipboard
object KtStateKey
Link copied to clipboard

This interface can be used only within exclusive handlers of virtual objects. It extends Context adding access to the virtual object instance key-value state storage.

Link copied to clipboard
@ApiStatus.Experimental
interface RestateClock
Link copied to clipboard
class RestateRandom(seed: Long) : Random
Link copied to clipboard
data class RetryPolicy(val initialDelay: Duration, val exponentiationFactor: Float, val maxDelay: Duration? = null, val maxAttempts: Int? = null, val maxDuration: Duration? = null)

Retry policy configuration.

Link copied to clipboard
sealed interface SelectBuilder<in R>
Link copied to clipboard
sealed interface SelectClause<T>
Link copied to clipboard
sealed interface SharedObjectContext : Context

This interface can be used only within shared handlers of virtual objects. It extends Context adding access to the virtual object instance key-value state storage.

Link copied to clipboard

This interface can be used only within shared handlers of workflow. It extends Context adding access to the workflow instance key-value state storage and to the DurablePromise API.

Link copied to clipboard

Opt-in annotation to use the preview of new context features.

Link copied to clipboard

This interface can be used only within workflow handlers of workflow. It extends Context adding access to the workflow instance key-value state storage and to the DurablePromise API.

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
@get:ApiStatus.Experimental
val Clock.Companion.Restate: RestateClock

Get RestateClock, that deterministically records the time.

Functions

Link copied to clipboard
suspend fun <T> awaitAll(vararg durableFutures: DurableFuture<T>): List<T>
Link copied to clipboard
suspend fun <T> Collection<DurableFuture<T>>.awaitAll(): List<T>

Like kotlinx.coroutines.awaitAll, but for DurableFuture.

Link copied to clipboard
@ApiStatus.Experimental
inline suspend fun <T : Any> awakeable(): Awakeable<T>
@ApiStatus.Experimental
suspend fun <T : Any> awakeable(typeTag: TypeTag<T>): Awakeable<T>

Create an Awakeable, addressable through Awakeable.id.

Link copied to clipboard
inline suspend fun <T : Any> Context.awakeable(): Awakeable<T>

Create an Awakeable, addressable through Awakeable.id.

Link copied to clipboard
@ApiStatus.Experimental
suspend fun awakeableHandle(id: String): AwakeableHandle

Create a new AwakeableHandle for the provided identifier.

Link copied to clipboard
suspend fun <Req, Res> Request<Req, Res>.call(context: Context): CallDurableFuture<Res>

Shorthand for Context.call

Link copied to clipboard
@ApiStatus.Experimental
fun clock(): RestateClock

Get RestateClock, that deterministically records the time.

Link copied to clipboard
@ApiStatus.Experimental
suspend fun context(): Context

Get the current Restate Context from within a handler.

Link copied to clipboard
Link copied to clipboard
@ApiStatus.Experimental
inline suspend fun <T : Any> KotlinState.get(key: String): T?

Gets the state stored under key.

inline suspend fun <T : Any> SharedObjectContext.get(key: String): T?
Link copied to clipboard
@ApiStatus.Experimental
inline suspend fun <R> invocationHandle(invocationId: String): InvocationHandle<R>

Get an InvocationHandle for an already existing invocation.

Link copied to clipboard
inline fun <Res> Context.invocationHandle(invocationId: String): InvocationHandle<Res>

Get an InvocationHandle for an already existing invocation. This will let you interact with a running invocation, for example to cancel it or retrieve its result.

Link copied to clipboard
@ApiStatus.Experimental
suspend fun objectKey(): String

Get the key of this Virtual Object.

Link copied to clipboard
@ApiStatus.Experimental
suspend fun <T : Any> promise(key: DurablePromiseKey<T>): DurablePromise<T>

Create a DurablePromise for the given key.

Link copied to clipboard
@ApiStatus.Experimental
suspend fun <T : Any> promiseHandle(key: DurablePromiseKey<T>): DurablePromiseHandle<T>

Create a new DurablePromiseHandle for the provided key.

Link copied to clipboard
@ApiStatus.Experimental
suspend fun random(): RestateRandom

Get the deterministic random instance.

Link copied to clipboard
@ApiStatus.Experimental
suspend fun request(): HandlerRequest

Get the current request information.

Link copied to clipboard
inline suspend fun <T : Any> AwakeableHandle.resolve(payload: T)

Complete with success the Awakeable.

Link copied to clipboard
Link copied to clipboard
@ApiStatus.Experimental
inline suspend fun <T : Any> runAsync(name: String = "", retryPolicy: RetryPolicy? = null, noinline block: suspend () -> T): DurableFuture<T>

Execute a closure asynchronously.

Link copied to clipboard
inline suspend fun <T : Any> Context.runAsync(name: String = "", retryPolicy: RetryPolicy? = null, noinline block: suspend () -> T): DurableFuture<T>

Execute a closure asynchronously. This is like runBlock, but it returns a DurableFuture that you can combine and select.

Link copied to clipboard
@ApiStatus.Experimental
inline suspend fun <T : Any> runBlock(name: String = "", retryPolicy: RetryPolicy? = null, noinline block: suspend () -> T): T

Execute a closure, recording the result value in the journal.

Link copied to clipboard
inline suspend fun <T : Any> Context.runBlock(name: String = "", retryPolicy: RetryPolicy? = null, noinline block: suspend () -> T): T

Execute a closure, recording the result value in the journal. The result value will be re-played in case of re-invocation (e.g. because of failure recovery or suspension point) without re-executing the closure.

Link copied to clipboard
inline suspend fun <R> select(crossinline builder: SelectBuilder<R>.() -> Unit): DurableFuture<R>

Like kotlinx.coroutines.selects.select, but for DurableFuture

Link copied to clipboard
suspend fun <Req, Res> Request<Req, Res>.send(context: Context, delay: Duration? = null): InvocationHandle<Res>

Shorthand for Context.send

Link copied to clipboard
@ApiStatus.Experimental
inline suspend fun <SVC : Any> service(): SVC

Create a proxy client for a Restate service.

Link copied to clipboard
@ApiStatus.Experimental
inline suspend fun <T : Any> KotlinState.set(key: String, value: T)

Sets the given value under the given key.

inline suspend fun <T : Any> ObjectContext.set(key: String, value: T)
Link copied to clipboard
@ApiStatus.Experimental
suspend fun sleep(duration: Duration)

Causes the current execution of the function invocation to sleep for the given duration.

Link copied to clipboard
@ApiStatus.Experimental
suspend fun state(): KotlinState

Access to this Virtual Object/Workflow state.

Link copied to clipboard
inline fun <T> stateKey(name: String): StateKey<T>
Link copied to clipboard
@ApiStatus.Experimental
suspend fun timer(name: String = "", duration: Duration): DurableFuture<Unit>

Causes the start of a timer for the given duration.

Link copied to clipboard
@ApiStatus.Experimental
inline fun <SVC : Any> toService(): KRequestBuilder<SVC>

Create a builder for invoking a Restate service from within a handler.

Link copied to clipboard
@ApiStatus.Experimental
inline fun <SVC : Any> toVirtualObject(key: String): KRequestBuilder<SVC>

Create a builder for invoking a Restate virtual object from within a handler.

Link copied to clipboard
@ApiStatus.Experimental
inline fun <SVC : Any> toWorkflow(key: String): KRequestBuilder<SVC>

Create a builder for invoking a Restate workflow from within a handler.

Link copied to clipboard
@ApiStatus.Experimental
inline suspend fun <SVC : Any> virtualObject(key: String): SVC

Create a proxy client for a Restate virtual object.

Link copied to clipboard
@ApiStatus.Experimental
inline suspend fun <SVC : Any> workflow(key: String): SVC

Create a proxy client for a Restate workflow.

Link copied to clipboard
@ApiStatus.Experimental
suspend fun workflowKey(): String

Get the key of this Workflow.