use crate::AppState;
use crate::api::health_capabilities::local_capabilities;
use crate::api::health_contracts::{ClusterHealthPayload, ClusterMirrorHealth};
use crate::api::health_status::{
athena_deadpool_status, gateway_auth_store_status, gateway_benchmark_client_status,
};
pub(super) fn apply_cluster_probe_metrics(
app_state: &AppState,
probes: Vec<(String, ClusterMirrorHealth)>,
) -> Vec<ClusterMirrorHealth> {
probes
.into_iter()
.map(|(url, probe)| {
app_state.metrics_state.set_cluster_probe(
&url,
crate::api::metrics::ClusterProbeMetric {
up: probe.status == "online",
latency_ms: probe.latency_ms,
download_bytes_per_sec: probe.download_bytes_per_sec,
},
);
probe
})
.collect()
}
pub(super) fn build_cluster_health_payload(
app_state: &AppState,
mirrors: Vec<ClusterMirrorHealth>,
) -> ClusterHealthPayload {
ClusterHealthPayload {
message: "Athena is online".to_string(),
version: env!("CARGO_PKG_VERSION").to_string(),
athena_api: "online".to_string(),
athena_deadpool: athena_deadpool_status(app_state).to_string(),
athena_scylladb: "online".to_string(),
gateway_auth_store: gateway_auth_store_status(app_state).to_string(),
gateway_benchmark_client: gateway_benchmark_client_status(app_state).to_string(),
cargo_toml_version: env!("CARGO_PKG_VERSION").to_string(),
capabilities: local_capabilities(),
mirrors,
}
}