aion_store_haematite/lib.rs
1//! Single-node [`haematite`]-backed implementation of Aion's `EventStore`.
2//!
3//! [`HaematiteStore`] persists Aion workflow history, durable timers, deployed
4//! packages, package routes, and the durable outbox on top of a single-node
5//! [`haematite::Database`], satisfying the same `aion_store::EventStore` contract
6//! the in-memory and libSQL stores satisfy. See [`store`] for the design and the
7//! event/KV key-encoding scheme.
8//!
9//! [`HaematiteStore`] runs in one of two modes. In **single-node** mode
10//! ([`HaematiteStore::create`]/[`HaematiteStore::open`]) every write is a local
11//! haematite commit (B1). In **distributed** mode
12//! ([`HaematiteStore::with_distribution`]) event appends are quorum-REPLICATED to
13//! a cluster membership over haematite's `replicate_append`, so a workflow's
14//! durable history survives the owner node's death and is readable on the
15//! survivor once it becomes the shard owner (B2). Workflows are enumerated from
16//! the replicated event streams themselves, so there is no separate workflow-id
17//! index. The outbox stays Design-B local and is rebuilt from the replicated
18//! history on the survivor.
19//!
20//! # Example
21//!
22//! ```no_run
23//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
24//! use aion_store::{ReadableEventStore, WorkflowId};
25//! use aion_store_haematite::HaematiteStore;
26//!
27//! let store = HaematiteStore::create("/tmp/aion-haematite-store")?;
28//! let workflow_id = WorkflowId::new_v4();
29//! let history = store.read_history(&workflow_id).await?;
30//! assert!(history.is_empty());
31//! # Ok(())
32//! # }
33//! ```
34
35mod error;
36mod keyspace;
37/// The [`HaematiteStore`] type and its `EventStore` trait implementations.
38pub mod store;
39
40pub use store::{ClusterBootstrap, ClusterResponder, HaematiteStore};