athena_rs 3.18.0

Hyper performant polyglot Database driver
Documentation
//! Health check endpoints for Athena RS.

use crate::AppState;
use crate::api::health_cluster_service::load_cluster_payload;
/// Backward-compatible re-export of cluster health payload contracts.
pub use crate::api::health_contracts::{ClusterHealthPayload, ClusterMirrorHealth};
use crate::api::health_endpoint_payload::{build_health_payload, build_root_health_payload};
use crate::provisioning::inspect_local_provisioning_dependencies;

use actix_web::{HttpResponse, get, web};
use serde_json::Value;

/// Returns root API metadata including capabilities and advertised routes.
#[get("/")]
pub async fn root(app_state: web::Data<AppState>) -> HttpResponse {
    let provisioning_status = inspect_local_provisioning_dependencies().await;
    let body: Value = build_root_health_payload(app_state.get_ref(), &provisioning_status);

    HttpResponse::Ok()
        .content_type("application/json")
        .json(body)
}

/// Returns local health metadata and provisioning diagnostics.
#[get("/health")]
pub async fn health(app_state: web::Data<AppState>) -> HttpResponse {
    let provisioning_status = inspect_local_provisioning_dependencies().await;
    let body: Value = build_health_payload(app_state.get_ref(), &provisioning_status);

    HttpResponse::Ok()
        .content_type("application/json")
        .json(body)
}

/// Returns cluster mirror health and capability diagnostics.
#[get("/health/cluster")]
pub async fn cluster_health(app_state: web::Data<AppState>) -> HttpResponse {
    HttpResponse::Ok().json(load_cluster_payload(app_state.get_ref()).await)
}

/// Lightweight liveness endpoint used by probes and mirror checks.
#[get("/ping")]
pub async fn ping() -> HttpResponse {
    HttpResponse::Ok()
        .content_type("text/plain; charset=utf-8")
        .body("pong")
}