athena_rs 3.26.1

Hyper performant polyglot Database driver
Documentation
//! Shared status helpers for health endpoints.
//!
//! This module centralizes lightweight status derivation used by `/` and
//! `/health` payload construction.

use crate::AppState;

/// Computes deadpool status based on whether at least one client pool is registered.
pub(super) fn athena_deadpool_status(app_state: &AppState) -> &'static str {
    if app_state.pg_registry.list_clients().is_empty() {
        "offline"
    } else {
        "online"
    }
}

/// Computes gateway auth-store status from configured auth client connectivity.
pub(super) fn gateway_auth_store_status(app_state: &AppState) -> &'static str {
    let Some(client_name) = app_state.gateway_auth_client_name.as_ref() else {
        return "not_configured";
    };
    if app_state.pg_registry.get_pool(client_name).is_some() {
        "online"
    } else {
        "unavailable"
    }
}

/// Computes gateway benchmark-client status from configured client connectivity.
pub(super) fn gateway_benchmark_client_status(app_state: &AppState) -> &'static str {
    let Some(client_name) = app_state.gateway_benchmark_client_name.as_ref() else {
        return "not_configured";
    };
    if app_state.pg_registry.get_pool(client_name).is_some() {
        "online"
    } else {
        "unavailable"
    }
}