feat(infra): transactional outbox — OutboxWriter port, PgOutboxWriter, OutboxRelay, TestOutbox; update create_thought + delete_thought

This commit is contained in:
2026-05-15 18:31:57 +02:00
parent 15b1d0fdb7
commit 6024a65060
16 changed files with 245 additions and 20 deletions

View File

@@ -1,6 +1,7 @@
mod dlq;
mod factory;
mod handlers;
mod outbox_relay;
use domain::ports::EventConsumer;
use futures::StreamExt;
@@ -26,6 +27,16 @@ async fn main() {
infra.event_publisher.clone(),
));
// Spawn outbox relay — polls DB for undelivered events and publishes them.
tokio::spawn(
outbox_relay::OutboxRelay {
pool: infra.pool.clone(),
publisher: infra.event_publisher.clone(),
poll_interval: std::time::Duration::from_secs(5),
}
.run(),
);
tracing::info!("Worker started, consuming events...");
let mut stream = infra.consumer.consume();
while let Some(result) = stream.next().await {