MemoryCheckpointer

class MemoryCheckpointer<State>(maxHistory: Int = Int.MAX_VALUE) : Checkpointer<State>

A Checkpointer that keeps checkpoints in memory. Intended for tests and short-lived processes. Safe to share between coroutines and threads.

Parameters

maxHistory

how many checkpoints a thread keeps, counted from the latest. The default keeps all of them; 1 keeps only the latest.

Throws

Constructors

Link copied to clipboard
constructor(maxHistory: Int = Int.MAX_VALUE)

Functions

Link copied to clipboard
open suspend override fun delete(threadId: String)

Removes every checkpoint of threadId. Does nothing if the thread has none.

Link copied to clipboard
open suspend override fun history(threadId: String): List<Checkpoint<State>>

Returns the checkpoints that threadId still has, oldest first, ending with the one that load returns. Empty if the thread has none.

Link copied to clipboard
open suspend override fun load(threadId: String): Checkpoint<State>?

Returns the latest checkpoint of threadId, or null if the thread has none.

Link copied to clipboard
open suspend override fun save(threadId: String, checkpoint: Checkpoint<State>)

Stores checkpoint as the latest checkpoint of threadId.