feat: processed-event ledger, idempotent dispatch
This commit is contained in:
16
crates/domain/src/ports/processed_events.rs
Normal file
16
crates/domain/src/ports/processed_events.rs
Normal 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>;
|
||||
}
|
||||
Reference in New Issue
Block a user