feat: add futures workspace dep, upgrade EventConsumer to BoxStream
This commit is contained in:
@@ -24,6 +24,7 @@ resolver = "2"
|
|||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
tokio = { version = "1.0", features = ["full"] }
|
tokio = { version = "1.0", features = ["full"] }
|
||||||
|
futures = "0.3"
|
||||||
dotenvy = "0.15"
|
dotenvy = "0.15"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
|
|||||||
@@ -9,5 +9,6 @@ chrono = { workspace = true }
|
|||||||
async-trait = { workspace = true }
|
async-trait = { workspace = true }
|
||||||
anyhow = { workspace = true }
|
anyhow = { workspace = true }
|
||||||
thiserror = { workspace = true }
|
thiserror = { workspace = true }
|
||||||
|
futures = { workspace = true }
|
||||||
|
|
||||||
email_address = "0.2.9"
|
email_address = "0.2.9"
|
||||||
|
|||||||
@@ -173,11 +173,10 @@ pub trait EventPublisher: Send + Sync {
|
|||||||
async fn publish(&self, event: &DomainEvent) -> Result<(), DomainError>;
|
async fn publish(&self, event: &DomainEvent) -> Result<(), DomainError>;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
|
||||||
pub trait EventConsumer: Send + Sync {
|
pub trait EventConsumer: Send + Sync {
|
||||||
/// Returns the next available event, or `None` if the stream has ended.
|
/// Returns a stream of domain events. Implementations decide whether this
|
||||||
/// Implementations decide whether this blocks (push) or polls (DB queue).
|
/// is push-based (NATS) or poll-based (DB queue) — callers don't care.
|
||||||
async fn next_event(&self) -> Result<Option<DomainEvent>, DomainError>;
|
fn consume(&self) -> futures::stream::BoxStream<'_, Result<DomainEvent, DomainError>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
|
|||||||
Reference in New Issue
Block a user