Expand description
PostgreSQL persistence backend for the Sayiir workflow engine.
This crate provides PostgresBackend, a production-grade implementation of
SnapshotStore,
SignalStore, and
TaskClaimStore backed by PostgreSQL via
sqlx.
§Features
- Codec-generic: Serialise snapshots with any codec (JSON for debuggability,
rkyv/bincode for speed). The data column is always
BYTEA. - ACID transactions: Composite signal operations (
check_and_cancel,check_and_pause,unpause) use single Postgres transactions withSELECT … FOR UPDATEfor true atomicity. - Snapshot history: Every checkpoint is appended to an immutable history table for debugging, auditing, and future replay.
- Observability-ready: Indexed metadata columns (
status,current_task_id,completed_task_count,error, timestamps) plus a denormalisedsayiir_workflow_taskstable enable monitoring without deserialising blobs. - Distributed task claiming:
TaskClaimStorewith TTL-based claims, expired-claim replacement, and soft worker bias.
§PostgreSQL version support
Minimum supported version: PostgreSQL 13. The schema uses
INSERT … ON CONFLICT DO UPDATE (9.5+) and ALTER TABLE … ADD COLUMN IF NOT EXISTS (9.6+); 13 is the floor because it is the oldest major release still
receiving security patches. Integration tests run against both 13 and 17.
§Quick start
use sayiir_postgres::PostgresBackend;
use sayiir_runtime::serialization::JsonCodec;
use sayiir_persistence::SnapshotStore;
use sayiir_core::snapshot::WorkflowSnapshot;
let backend = PostgresBackend::<JsonCodec>::connect("postgresql://localhost/sayiir").await?;
let mut snapshot = WorkflowSnapshot::new("order-123", sayiir_core::DefinitionHash::from("hash-abc"));
backend.save_snapshot(&mut snapshot).await?;
let loaded = backend.load_snapshot("order-123").await?;Structs§
- Pool
Options - Connection-pool configuration for the Postgres backend.
- Postgres
Backend - PostgreSQL persistence backend for Sayiir workflows.
Constants§
- WORKFLOW_
CHILD_ TABLES - Per-instance child tables — i.e. everything that holds rows keyed by
instance_idother thansayiir_workflow_snapshotsitself. Source of truth for bothdelete_snapshot’s cleanup loop and the benchmark’sreset_sayiir_tablestruncate.
Functions§
- wakeup_
drops_ total - Snapshot of the wakeup-drop counter. Monotonic; a benchmark records the value at scenario start and again at scenario end and reports the delta.