mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-17 21:15:32 +09:00
refactor(gateway): share shard helpers and test fixtures (#3381)
This commit is contained in:
1 parent
f22261f218
commit
e7b13fd19f
25 files changed
+101
-2021
No files matched your search
@@ -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"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user