nixfleet_control_plane/server/routes/
health.rs

1//! `GET /healthz` - outside `/v1/*` so it bypasses the protocol-version middleware.
2
3use std::sync::Arc;
4
5use axum::Json;
6use axum::extract::State;
7use serde::Serialize;
8
9use super::super::state::AppState;
10
11#[derive(Debug, Serialize)]
12pub(in crate::server) struct HealthzResponse {
13    ok: bool,
14    version: &'static str,
15    /// RFC3339 UTC; `null` until the reconcile loop ticks once.
16    last_tick_at: Option<String>,
17}
18
19pub(in crate::server) async fn healthz(state: State<Arc<AppState>>) -> Json<HealthzResponse> {
20    let last = *state.last_tick_at.read().await;
21    Json(HealthzResponse {
22        ok: true,
23        version: env!("CARGO_PKG_VERSION"),
24        last_tick_at: last.map(|t| t.to_rfc3339()),
25    })
26}