Package-level declarations

Types

Link copied to clipboard

Converts the checkpoints of a thread to and from a string, so a Checkpointer for any storage only has to read and write strings:

Link copied to clipboard
class KotlinxStateSerializer<State>(serializer: KSerializer<State>, json: Json = Json) : StateSerializer<State>

A StateSerializer backed by kotlinx.serialization, for states annotated with @Serializable.

Functions

Link copied to clipboard
inline fun <reified State> CheckpointCodec(json: Json = Json): CheckpointCodec<State>

Creates a CheckpointCodec for the reified @Serializable State type.

Link copied to clipboard
inline suspend fun <reified T> effect(key: String, json: Json = Json, noinline block: suspend () -> T): T

Runs block, a side effect such as a payment or an email, once for the step of the node that calls it, and returns its result, which a Json of json saves. T is a @Serializable class, a basic type such as String, or Unit for an effect without a result.

inline suspend fun <reified T> effect(key: String, json: Json = Json, noinline reconcile: suspend (id: String) -> T?, noinline block: suspend (id: String) -> T): T

Runs block once for the step of the node that calls it, with an id to pass to the service as its idempotency key, and asks reconcile when the step runs again after block started but before its result was saved. T is saved by a Json of json, as for the effect without reconcile.

Link copied to clipboard
inline suspend fun <reified T> Store.get(namespace: List<String>, key: String, json: Json = Json): T?

Returns the value under key in namespace as a T, which a Json of json reads, or null when there is none. T is a @Serializable class or a basic type.

Link copied to clipboard
inline fun <reified State> KotlinxStateSerializer(json: Json = Json): KotlinxStateSerializer<State>

Creates a KotlinxStateSerializer for the reified @Serializable State type.

Link copied to clipboard
inline suspend fun <reified T> Store.put(namespace: List<String>, key: String, value: T, json: Json = Json)

Keeps value under key in namespace, which a Json of json writes. T is a @Serializable class or a basic type. A String is kept as it is, by Store.put.