feat: worker relays outbox to nats

This commit is contained in:
2026-10-26 00:06:09 +01:00
parent 32dfc84697
commit c06d3d9207
15 changed files with 678 additions and 102 deletions

View File

@@ -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>>;
}