Watch
0
0
Fork
You've already forked hyperhive
0

swarm-controller: serve reads the tcp listener config itself, keeping main under the line limit

This commit is contained in:
maia 2026-11-20 19:09:00 +01:00 • committed by mara
commit 0e147618d0

View file

@ -271,14 +271,7 @@ async fn main() -> Result<()> {
reviews: Arc::default(),
alerts: alerts::from_env(),
};
serve(
listener,
tcp_tls::TcpTlsConfig::from_env()?,
state,
stop,
health,
)
.await
serve(listener, state, stop, health).await
}
/// The value a startup step produced, or exit 0 when the stop signal ended the
@ -327,18 +320,19 @@ fn register_cert_gauges(provider: Option<&opentelemetry_sdk::metrics::SdkMeterPr
}
/// Start taking the queued review requests and answering the notification
/// router's, then serve `state` on `listener`, and on `tcp` too when it is
/// configured, until `stop` resolves. Both answer from the same router and
/// both drain on `stop`. The requests in hand finish for at most the drain;
/// router's, then serve `state` on `listener`, and on the TCP listener too when
/// its environment is configured (a half-set one refuses to start, before
/// anything is served), until `stop` resolves. Both answer from the same router
/// and both drain on `stop`. The requests in hand finish for at most the drain;
/// the review queue takes no request after `stop`. `health` answers `/readyz`
/// as the socket's does.
async fn serve(
listener: tokio::net::UnixListener,
tcp: Option<tcp_tls::TcpTlsConfig>,
state: AppState,
stop: impl Future<Output = ()> + Clone + Send + 'static,
health: swarm_secret_client::health::Health,
) -> Result<()> {
let tcp = tcp_tls::TcpTlsConfig::from_env()?;
let store = routes::watch_store();
health.ready_when(routes::probe_condition(state.status.clone(), store));
review_classifier::review::spawn_queue(&state, stop.clone());