sayiir-postgres
PostgreSQL persistence backend for the Sayiir durable workflow engine.
Overview
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 use
SELECT … FOR UPDATEfor true atomicity. - Snapshot history — Every checkpoint is appended to an immutable history table for debugging and auditing.
- 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 — TTL-based claims with expired-claim replacement and soft worker bias.
Quick Start
use PostgresBackend;
use JsonCodec;
use SnapshotStore;
use WorkflowSnapshot;
async
Schema
PostgresBackend::connect() runs migrations automatically. The schema consists of:
| Table | Purpose |
|---|---|
sayiir_workflows |
Current snapshot per workflow instance |
sayiir_workflow_history |
Immutable append-only snapshot history |
sayiir_workflow_tasks |
Denormalised task metadata for querying |
sayiir_task_claims |
Distributed task claim tracking |
sayiir_workflow_events |
Event log for workflow lifecycle |
PostgreSQL Version Support
Minimum supported version: PostgreSQL 13. Integration tests run against both 13 and 17.
Documentation
Full API docs are available on docs.rs.
License
MIT