Skip to main content

a3s_flow/store/
mod.rs

1use async_trait::async_trait;
2
3use crate::error::Result;
4use crate::model::{FlowEvent, FlowEventEnvelope};
5
6mod local_file;
7mod memory;
8#[cfg(any(feature = "postgres", feature = "sqlite"))]
9mod migrations;
10#[cfg(feature = "postgres")]
11mod postgres;
12mod retention;
13#[cfg(feature = "sqlite")]
14mod sqlite;
15
16pub use local_file::LocalFileEventStore;
17pub use memory::InMemoryEventStore;
18#[cfg(feature = "postgres")]
19pub(crate) use migrations::postgres_migrations;
20#[cfg(feature = "sqlite")]
21pub(crate) use migrations::sqlite_migrations;
22#[cfg(feature = "postgres")]
23pub use postgres::PostgresEventStore;
24#[cfg(any(feature = "postgres", feature = "sqlite"))]
25pub use retention::{
26    FlowHistoryHold, FlowHistoryRetentionPolicy, FlowHistoryRetentionReport, FlowHistoryTombstone,
27};
28#[cfg(feature = "sqlite")]
29pub use sqlite::SqliteEventStore;
30
31/// Append-only event store for durable workflow runs.
32#[async_trait]
33pub trait FlowEventStore: Send + Sync {
34    async fn append(&self, run_id: &str, event: FlowEvent) -> Result<FlowEventEnvelope>;
35
36    async fn append_if_sequence(
37        &self,
38        run_id: &str,
39        expected_sequence: u64,
40        event: FlowEvent,
41    ) -> Result<FlowEventEnvelope>;
42
43    async fn list(&self, run_id: &str) -> Result<Vec<FlowEventEnvelope>>;
44
45    async fn list_run_ids(&self) -> Result<Vec<String>>;
46}