feat: worker relays outbox to nats
This commit is contained in:
@@ -2,7 +2,7 @@ use async_trait::async_trait;
|
||||
|
||||
use crate::{
|
||||
errors::DomainError,
|
||||
events::{DomainEvent, EventEnvelope},
|
||||
events::{DomainEvent, EventEnvelope, EventId},
|
||||
};
|
||||
|
||||
#[async_trait]
|
||||
@@ -10,6 +10,13 @@ pub trait EventPublisher: Send + Sync {
|
||||
async fn publish(&self, event: &DomainEvent) -> Result<(), DomainError>;
|
||||
}
|
||||
|
||||
/// Delivers one outbox row to the message bus. `Ok` means the bus accepted it
|
||||
/// (for a brokered bus: acknowledged), so the row may be marked done.
|
||||
#[async_trait]
|
||||
pub trait EventRelaySink: Send + Sync {
|
||||
async fn relay(&self, id: Option<&EventId>, event: &DomainEvent) -> Result<(), DomainError>;
|
||||
}
|
||||
|
||||
pub trait EventConsumer: Send + Sync {
|
||||
fn consume(&self) -> futures::stream::BoxStream<'_, Result<EventEnvelope, DomainError>>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user