feat: event store — persist domain events to Postgres event_log table via composite publisher
This commit is contained in:
@@ -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>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user