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