feat: event ids, outbox identity migration

This commit is contained in:
2026-10-25 23:57:24 +01:00
parent c31aa033cc
commit 32dfc84697
14 changed files with 287 additions and 39 deletions

View File

@@ -26,23 +26,14 @@ impl EventBusBackend {
}
}
/// The server's publisher is always the outbox writer: it never talks to the
/// bus, whatever `EVENT_BUS_BACKEND` says. The worker owns delivery.
pub async fn create_publisher(
db_pool: &sqlx::SqlitePool,
config: &config::AppConfig,
) -> anyhow::Result<Arc<dyn EventPublisher>> {
match EventBusBackend::from_config(&config.events)? {
EventBusBackend::Db => {
tracing::info!("event bus: DB queue");
Ok(sqlite::SqliteEventQueue::create_publisher(db_pool.clone(), &config.events).await?)
}
#[cfg(feature = "nats")]
EventBusBackend::Nats => {
let cfg = nats::NatsConfig::from_config(&config.nats)
.context("EVENT_BUS_BACKEND=nats requires NATS_URL to be set")?;
tracing::info!("event bus: NATS ({})", cfg.url);
Ok(nats::create_publisher(cfg).await?)
}
}
tracing::info!("event publisher: outbox (DB queue)");
sqlite::SqliteEventQueue::create_publisher(db_pool.clone(), &config.events).await
}
pub async fn create_channel(