feat: add futures workspace dep, upgrade EventConsumer to BoxStream

This commit is contained in:
2026-05-10 02:52:37 +02:00
parent a8092a140d
commit e8b1685c9e
3 changed files with 5 additions and 4 deletions

View File

@@ -9,5 +9,6 @@ chrono = { workspace = true }
async-trait = { workspace = true }
anyhow = { workspace = true }
thiserror = { workspace = true }
futures = { workspace = true }
email_address = "0.2.9"

View File

@@ -173,11 +173,10 @@ pub trait EventPublisher: Send + Sync {
async fn publish(&self, event: &DomainEvent) -> Result<(), DomainError>;
}
#[async_trait]
pub trait EventConsumer: Send + Sync {
/// Returns the next available event, or `None` if the stream has ended.
/// Implementations decide whether this blocks (push) or polls (DB queue).
async fn next_event(&self) -> Result<Option<DomainEvent>, DomainError>;
/// Returns a stream of domain events. Implementations decide whether this
/// is push-based (NATS) or poll-based (DB queue) — callers don't care.
fn consume(&self) -> futures::stream::BoxStream<'_, Result<DomainEvent, DomainError>>;
}
#[async_trait]