refactor(gateway): share shard helpers and test fixtures (#3381)

This commit is contained in:
Hampus authored and GitHub committed 2026-10-10 23:04:30 +02:00
1 parent f22261f218
commit e7b13fd19f
25 files changed
+101 -2021

No files matched your search

-28
View File
@@ -26,31 +26,3 @@ pub fn init_tracing() {
.try_init()
.ok();
}
pub async fn run<S>(service: S) -> anyhow::Result<()>
where
S: router::RouterService,
S::Response: Clone,
{
init_tracing();
let config = config::ServiceConfig::from_env()?;
let transport =
transport::NatsTransport::connect(&config.nats_url, config.nats_auth_token.as_deref())
.await?;
tracing::info!(
service = config.service_name,
mode = ?config.mode,
shard_id = config.shard_id,
shard_count = config.shard_count,
listen_addr = %config.listen_addr,
"starting service"
);
match config.mode {
config::Mode::Router => router::run_router(&config, service, transport).await,
config::Mode::Shard => {
anyhow::bail!(
"run() with RouterService cannot be used in shard mode; use run_shard() directly"
)
}
}
}