diff --git a/Cargo.toml b/Cargo.toml index 7d02e99..1532dbf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,6 +24,7 @@ resolver = "2" [workspace.dependencies] tokio = { version = "1.0", features = ["full"] } +futures = "0.3" dotenvy = "0.15" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" diff --git a/crates/domain/Cargo.toml b/crates/domain/Cargo.toml index 5ccb5cd..9093117 100644 --- a/crates/domain/Cargo.toml +++ b/crates/domain/Cargo.toml @@ -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" diff --git a/crates/domain/src/ports.rs b/crates/domain/src/ports.rs index 0f03b81..eb00ab3 100644 --- a/crates/domain/src/ports.rs +++ b/crates/domain/src/ports.rs @@ -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, 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>; } #[async_trait]