feat: event store — persist domain events to Postgres event_log table via composite publisher

This commit is contained in:
2026-05-31 18:36:10 +02:00
parent d022cb9068
commit aa09aec66b
10 changed files with 143 additions and 10 deletions

View File

@@ -1,5 +1,6 @@
use crate::common::errors::DomainError;
use crate::common::events::{DomainEvent, EventEnvelope};
use crate::common::value_objects::SystemId;
use async_trait::async_trait;
use futures::stream::BoxStream;
@@ -11,3 +12,9 @@ pub trait EventPublisher: Send + Sync {
pub trait EventConsumer: Send + Sync {
fn consume(&self) -> BoxStream<'_, Result<EventEnvelope, DomainError>>;
}
#[async_trait]
pub trait EventStore: Send + Sync {
async fn append(&self, event: &DomainEvent) -> Result<(), DomainError>;
async fn query_by_aggregate(&self, aggregate_id: &SystemId) -> Result<Vec<DomainEvent>, DomainError>;
}