saga/storage/memory
Stores executions’ checkpoints in memory, in one actor process.
Use this adapter for tests, and for saga/durable runs that must survive
the loss of their runner or caller but not of the VM. One store holds
every execution, each under its own id. Use saga/storage/file when a
run must survive VM shutdown, or the saga_postgres package to share
runs across VMs.
import saga/durable
import saga/storage/memory
let assert Ok(store) = memory.start()
let assert Ok(run) =
durable.start_or_reconnect(persistence, memory.storage(store), id: "order-1", input: order)
// ...
memory.stop(store)
Under a supervisor, name the store and find it by name; the handle stays valid across restarts, which lose every saved execution:
let name = process.new_name("checkouts")
let child = memory.supervised(name)
// ... after the supervisor started:
let storage = memory.storage(memory.named(name))
A claim ends when it is released or when the process that took it exits;
a runner’s claim therefore ends with its runner. Each operation waits
at most 5 seconds for the store, then fails with storage.TimedOut.
Types
Values
pub fn named(name: process.Name(Message)) -> Memory
The store registered under name, whether or not it runs yet.
pub fn start() -> Result(Memory, actor.StartError)
Starts a store linked to the calling process.
pub fn supervised(
name: process.Name(Message),
) -> supervision.ChildSpecification(Memory)
A child specification that starts a store registered under name. Find
it with named(name).