feat: wire NATS event publisher into bootstrap + worker

- Both binaries connect to NATS on startup, ensure JetStream stream
- EventPublisherAdapter<NatsTransport> replaces LogEventPublisher
- nats_url config with default nats://localhost:4222
- Deleted bootstrap's LogEventPublisher (no longer needed)
This commit is contained in:
2026-05-31 11:53:51 +02:00
parent 0e9911ebfc
commit 838ed9a3f8
11 changed files with 35 additions and 36 deletions

View File

@@ -55,13 +55,15 @@ use presentation::{
};
use crate::config::Config;
use crate::log_event_publisher::LogEventPublisher;
use crate::log_sidecar_writer::LogSidecarWriter;
pub async fn build_app(config: &Config) -> Result<Router> {
let pool = connect(&config.database_url).await?;
run_migrations(&pool).await?;
let nats_client = async_nats::connect(&config.nats_url).await?;
adapters_nats::ensure_stream(&nats_client).await?;
// Identity
let user_repo = Arc::new(PostgresUserRepository::new(pool.clone()));
let hasher = Arc::new(BcryptPasswordHasher);
@@ -91,7 +93,9 @@ pub async fn build_app(config: &Config) -> Result<Router> {
let batch_repo = Arc::new(PostgresJobBatchRepository::new(pool.clone()));
let plugin_repo = Arc::new(PostgresPluginRepository::new(pool.clone()));
let pipeline_repo = Arc::new(PostgresPipelineRepository::new(pool.clone()));
let event_publisher: Arc<LogEventPublisher> = Arc::new(LogEventPublisher);
let transport = adapters_nats::NatsTransport::new(nats_client);
let event_publisher: Arc<dyn domain::ports::EventPublisher> =
Arc::new(event_transport::EventPublisherAdapter::new(transport));
let sidecar_writer: Arc<LogSidecarWriter> = Arc::new(LogSidecarWriter);
// File storage