Skip to main content

Crate sayiir_persistence

Crate sayiir_persistence 

Source
Expand description

Persistence layer for workflow execution state.

This crate provides traits and implementations for persisting workflow execution state, enabling distributed execution with checkpoint/restore capabilities.

§Trait Hierarchy

The persistence layer is built around focused sub-traits:

  • SnapshotStore: Core CRUD for workflow snapshots (5 methods).
  • SignalStore: Cancel + pause signal primitives with default composite implementations (3 required + 3 default methods).
  • TaskClaimStore: Distributed task claiming (4 methods, opt-in).
  • PersistentBackend: Supertrait = SnapshotStore + SignalStore, blanket-implemented so backends never need to impl it directly.

A minimal backend only needs 8 methods (SnapshotStore + 3 SignalStore primitives) to satisfy PersistentBackend.

§Example

use sayiir_persistence::{InMemoryBackend, SnapshotStore};
use sayiir_core::snapshot::WorkflowSnapshot;

// Create a backend (could be Redis, PostgreSQL, etc.)
let backend = InMemoryBackend::new();

// Save a snapshot
let mut snapshot = WorkflowSnapshot::new("instance-123", sayiir_core::DefinitionHash::from("hash-abc"));
backend.save_snapshot(&mut snapshot).await?;

// Load it back
let loaded = backend.load_snapshot("instance-123").await?;

Modules§

validation
Shared validation helpers for persistence backends.

Structs§

InMemoryBackend
In-memory backend that stores snapshots in a HashMap.
TaskWakeupHint
Routing-and-eligibility hint a producer attaches to a “task ready” wakeup. Workers consume it to:

Enums§

BackendError
Error type for backend operations.
PrepareRunOutcome
Outcome of prepare_run.
RunConflict
Reasons prepare_run may reject a call.

Traits§

PersistentBackend
Supertrait combining SnapshotStore and SignalStore.
SignalStore
Signal storage for cancel and pause workflows.
SnapshotStore
Core snapshot CRUD operations.
TaskClaimStore
Task claiming for distributed multi-worker execution.
TaskResultStore
Read-only access to individual task results from a workflow instance.

Functions§

prepare_run
Prepare a workflow run while honouring the configured ConflictPolicy.