feat(bootstrap): wire EventPublisherAdapter<NatsTransport> — transport-agnostic event publishing
This commit is contained in:
@@ -16,6 +16,7 @@ postgres-federation = { workspace = true }
|
|||||||
activitypub = { workspace = true }
|
activitypub = { workspace = true }
|
||||||
activitypub-base = { workspace = true }
|
activitypub-base = { workspace = true }
|
||||||
nats = { workspace = true }
|
nats = { workspace = true }
|
||||||
|
event-publisher = { workspace = true }
|
||||||
auth = { workspace = true }
|
auth = { workspace = true }
|
||||||
sqlx = { workspace = true }
|
sqlx = { workspace = true }
|
||||||
async-nats = { workspace = true }
|
async-nats = { workspace = true }
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ use sqlx::PgPool;
|
|||||||
use activitypub::ThoughtsObjectHandler;
|
use activitypub::ThoughtsObjectHandler;
|
||||||
use activitypub_base::{ApFederationConfig, FederationData};
|
use activitypub_base::{ApFederationConfig, FederationData};
|
||||||
use domain::{errors::DomainError, events::DomainEvent, ports::EventPublisher};
|
use domain::{errors::DomainError, events::DomainEvent, ports::EventPublisher};
|
||||||
|
use event_publisher::EventPublisherAdapter;
|
||||||
|
use nats::NatsTransport;
|
||||||
use postgres::activitypub::PgActivityPubRepository;
|
use postgres::activitypub::PgActivityPubRepository;
|
||||||
use postgres_federation::{PostgresApUserRepository, PostgresFederationRepository};
|
use postgres_federation::{PostgresApUserRepository, PostgresFederationRepository};
|
||||||
use presentation::state::AppState;
|
use presentation::state::AppState;
|
||||||
@@ -40,7 +42,7 @@ pub async fn build(cfg: &Config) -> Infrastructure {
|
|||||||
Some(url) => match async_nats::connect(url).await {
|
Some(url) => match async_nats::connect(url).await {
|
||||||
Ok(client) => {
|
Ok(client) => {
|
||||||
tracing::info!("Connected to NATS at {url}");
|
tracing::info!("Connected to NATS at {url}");
|
||||||
Arc::new(nats::NatsEventPublisher::new(client))
|
Arc::new(EventPublisherAdapter::new(NatsTransport::new(client)))
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
tracing::warn!("NATS connect failed ({e}) — falling back to no-op publisher");
|
tracing::warn!("NATS connect failed ({e}) — falling back to no-op publisher");
|
||||||
|
|||||||
Reference in New Issue
Block a user