SharedWorkflowContext

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.

NOTE: This interface MUST NOT be accessed concurrently since it can lead to different orderings of user actions, corrupting the execution of the invocation.

See also

Inheritors

Functions

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

Create a new AwakeableHandle for the provided identifier. You can use it to AwakeableHandle.resolve or AwakeableHandle.reject the linked Awakeable.

Link copied to clipboard
abstract suspend fun <Req, Res> call(request: Request<Req, Res>): CallDurableFuture<Res>

Invoke another Restate handler.

Link copied to clipboard
abstract suspend fun <T : Any> get(key: StateKey<T>): T?

Gets the state stored under key, deserializing the raw value using the StateKey.serdeInfo.

Link copied to clipboard
inline suspend fun <T : Any> SharedObjectContext.get(key: String): T?
Link copied to clipboard
abstract fun <Res> invocationHandle(invocationId: String, responseTypeTag: TypeTag<Res>): 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
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
abstract fun key(): String
Link copied to clipboard
abstract fun <T : Any> promise(key: DurablePromiseKey<T>): DurablePromise<T>

Create a DurablePromise for the given key.

Link copied to clipboard

Create a new DurablePromiseHandle for the provided key. You can use it to DurablePromiseHandle.resolve or DurablePromiseHandle.reject the given DurablePromise.

Link copied to clipboard
abstract fun random(): RestateRandom

Create a RestateRandom instance inherently predictable, seeded on the dev.restate.sdk.common.InvocationId, which is not secret.

Link copied to clipboard
abstract fun request(): HandlerRequest
Link copied to clipboard
abstract suspend fun <T> runAsync(typeTag: TypeTag<T>, name: String = "", retryPolicy: RetryPolicy? = null, 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
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
open suspend fun <T> runBlock(typeTag: TypeTag<T>, name: String = "", retryPolicy: RetryPolicy? = null, 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 <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
abstract suspend fun <Req, Res> send(request: Request<Req, Res>, delay: Duration? = null): InvocationHandle<Res>

Invoke another Restate handler without waiting for the response.

Link copied to clipboard
open suspend fun sleep(duration: Duration)

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

Link copied to clipboard
abstract suspend fun stateKeys(): Collection<String>

Gets all the known state keys for this virtual object instance.

Link copied to clipboard
abstract suspend fun timer(duration: Duration, name: String? = null): DurableFuture<Unit>

Causes the start of a timer for the given duration. You can await on the timer end by invoking DurableFuture.await.