use async_trait::async_trait;
use super::Event;
#[async_trait]
pub trait EventStoreBackend<E: Event>: Send + Sync {
async fn append(&self, aggregate_id: &str, events: Vec<E>) -> Result<(), String>;
async fn get_events(&self, aggregate_id: &str) -> Result<Vec<E>, String>;
async fn get_all_events(&self) -> Result<Vec<E>, String>;
async fn get_events_after(&self, aggregate_id: &str, version: u64) -> Result<Vec<E>, String>;
async fn save_snapshot(
&self,
aggregate_id: &str,
snapshot_data: Vec<u8>,
version: u64,
) -> Result<(), String> {
let _ = (aggregate_id, snapshot_data, version);
Ok(()) }
async fn get_latest_snapshot(&self, aggregate_id: &str) -> Result<(Vec<u8>, u64), String> {
let _ = aggregate_id;
Err("Snapshots not supported by this backend".to_string())
}
async fn flush(&self) -> Result<(), String> {
Ok(()) }
async fn stats(&self) -> BackendStats {
BackendStats::default()
}
}
#[derive(Debug, Clone, Default)]
pub struct BackendStats {
pub total_events: u64,
pub total_aggregates: u64,
pub total_snapshots: u64,
pub backend_specific: std::collections::HashMap<String, String>,
}