Skip to main content

synapse_proxy/
health.rs

1//! Liveness/readiness probes. Readiness flips to 503 once shutdown begins so
2//! load balancers drain this instance before in-flight requests finish.
3
4use std::sync::atomic::Ordering;
5
6use axum::extract::State;
7use axum::http::StatusCode;
8
9use crate::proxy::AppState;
10
11pub async fn liveness() -> StatusCode {
12    StatusCode::OK
13}
14
15pub async fn readiness(State(state): State<AppState>) -> StatusCode {
16    if state.shutting_down.load(Ordering::SeqCst) {
17        StatusCode::SERVICE_UNAVAILABLE
18    } else {
19        StatusCode::OK
20    }
21}