Skip to main content

zagens_runtime_api/
health.rs

1//! Health and internal probe routes (R-003 A4.5).
2
3use axum::Json;
4use axum::extract::State;
5use serde::Serialize;
6
7use zagens_runtime_orchestrator::runtime_threads::CURRENT_EVENT_SCHEMA_VERSION;
8
9use crate::state::RuntimeApiProbeState;
10
11#[derive(Debug, Serialize)]
12pub struct HealthResponse {
13    status: &'static str,
14    service: &'static str,
15    mode: &'static str,
16    event_schema_version: u32,
17}
18
19#[derive(Debug, Serialize)]
20pub struct InternalProbeResponse {
21    status: &'static str,
22    pid: u32,
23    started_at_ms: u128,
24    token_fingerprint: String,
25    version: &'static str,
26}
27
28pub async fn health() -> Json<HealthResponse> {
29    Json(HealthResponse {
30        status: "ok",
31        service: "zagens-runtime-api",
32        mode: "local",
33        event_schema_version: CURRENT_EVENT_SCHEMA_VERSION,
34    })
35}
36
37pub async fn internal_probe<S>(State(state): State<S>) -> Json<InternalProbeResponse>
38where
39    S: RuntimeApiProbeState,
40{
41    Json(InternalProbeResponse {
42        status: "ok",
43        pid: std::process::id(),
44        started_at_ms: state.process_started_at_ms(),
45        token_fingerprint: state.token_fingerprint().to_string(),
46        version: state.service_version(),
47    })
48}