Skip to main content

blazen_persist/
lib.rs

1//! # `Blazen` Persistence
2//!
3//! Provides checkpoint storage for workflow state, enabling pause/resume and
4//! crash recovery.
5//!
6//! ## Backends
7//!
8//! Two storage backends are available behind feature flags:
9//!
10//! | Feature | Backend | Description |
11//! |---------|---------|-------------|
12//! | `redb` (default) | [`RedbCheckpointStore`] | Embedded, pure-Rust ACID key-value store |
13//! | `valkey` | [`valkey::ValkeyCheckpointStore`] | Redis/ValKey server-backed store |
14//!
15//! ## Quick start (redb)
16//!
17//! ```rust,no_run
18//! use blazen_persist::{CheckpointStore, RedbCheckpointStore, WorkflowCheckpoint};
19//!
20//! # async fn example() -> Result<(), blazen_persist::PersistError> {
21//! let store = RedbCheckpointStore::new("workflow.db")?;
22//!
23//! // Save a checkpoint
24//! # let checkpoint = WorkflowCheckpoint {
25//! #     workflow_name: "demo".into(),
26//! #     run_id: uuid::Uuid::new_v4(),
27//! #     timestamp: chrono::Utc::now(),
28//! #     state: Default::default(),
29//! #     pending_events: vec![],
30//! #     metadata: Default::default(),
31//! # };
32//! store.save(&checkpoint).await?;
33//!
34//! // Load it back
35//! let loaded = store.load(&checkpoint.run_id).await?;
36//! # Ok(())
37//! # }
38//! ```
39
40pub mod checkpoint;
41pub mod error;
42
43#[cfg(feature = "valkey")]
44pub mod valkey;
45
46// Always-available exports (trait + data types + error).
47pub use checkpoint::{CheckpointStore, SerializedEvent, WorkflowCheckpoint};
48pub use error::PersistError;
49
50// Backend-specific re-exports.
51#[cfg(feature = "redb")]
52pub use checkpoint::RedbCheckpointStore;