ObjectContext

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.

Inheritors

Functions

Link copied to clipboard
abstract suspend fun <T : Any> awakeable(serde: Serde<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 using KtSerdes.json deserializer, 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
open suspend fun <T, R> call(target: Target, inputSerde: Serde<T>, outputSerde: Serde<R>, parameter: T): R

Invoke another Restate service method and wait for the response. Same as call(methodDescriptor, parameter).await().

Link copied to clipboard
abstract suspend fun <T, R> callAsync(target: Target, inputSerde: Serde<T>, outputSerde: Serde<R>, parameter: T): Awaitable<R>

Invoke another Restate service method.

Link copied to clipboard
abstract suspend fun clear(key: StateKey<*>)

Clears the state stored under key.

Link copied to clipboard
abstract suspend fun clearAll()

Clears all the state of this virtual object instance key-value state storage

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.serde.

Link copied to clipboard
abstract fun key(): String
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(): Request
Link copied to clipboard
abstract suspend fun <T> runBlock(serde: Serde<T>, name: String = "", block: suspend () -> T): T

Execute a non-deterministic 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. Use this feature if you want to perform non-deterministic operations.

abstract suspend fun <T> runBlock(serde: Serde<T>, name: String = "", retryPolicy: RetryPolicy? = null, block: suspend () -> T): T

Like runBlock, but using a custom retry policy.

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

Execute a non-deterministic closure, recording the result value in the journal using KtSerdes.json. 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. Use this feature if you want to perform non-deterministic operations.

inline suspend fun <T : Any> Context.runBlock(name: String = "", retryPolicy: RetryPolicy? = null, noinline block: suspend () -> T): T
Link copied to clipboard
abstract suspend fun <T> send(target: Target, inputSerde: Serde<T>, parameter: T, delay: Duration = Duration.ZERO)

Invoke another Restate service without waiting for the response.

Link copied to clipboard
abstract suspend fun <T : Any> set(key: StateKey<T>, value: T)

Sets the given value under the given key, serializing the value using the StateKey.serde.

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): Awaitable<Unit>

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