summaryrefslogtreecommitdiffstats
path: root/src/api/health.rs
blob: b1e452385ee0c0c5e788c888b0b9060c93006d4d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
//! `GET /health` and `GET /ready`: unauthenticated, for supervisors and load balancers.
//! They say whether the node is up and whether it serves the store, nothing more.

use axum::{extract::State, http::StatusCode};

use crate::state::AppState;

/// The HTTP API is up.
pub(crate) async fn health() -> &'static str {
    "ok\n"
}

/// The node serves reads and writes: ready, not joining or rejoining.
pub(crate) async fn ready(State(state): State<AppState>) -> (StatusCode, &'static str) {
    if state.is_ready().await {
        (StatusCode::OK, "ready\n")
    } else {
        (StatusCode::SERVICE_UNAVAILABLE, "not ready\n")
    }
}