feat: processed-event ledger, idempotent dispatch

This commit is contained in:
2026-10-26 00:17:28 +01:00
parent fa8e94817a
commit 5681d0c034
29 changed files with 610 additions and 24 deletions

View File

@@ -0,0 +1,16 @@
use async_trait::async_trait;
use crate::{errors::DomainError, events::EventId};
/// Records which handler has already completed which event, so a redelivered
/// event does not re-run handlers that succeeded.
#[async_trait]
pub trait ProcessedEventLedger: Send + Sync {
async fn has_processed(&self, id: &EventId, handler: &str) -> Result<bool, DomainError>;
/// Idempotent: recording an existing pair is not an error.
async fn record_processed(&self, id: &EventId, handler: &str) -> Result<(), DomainError>;
/// Returns the number of rows removed.
async fn delete_older_than(&self, cutoff: chrono::NaiveDateTime) -> Result<u64, DomainError>;
}