athena_rs 3.18.0

Hyper performant polyglot Database driver
Documentation
//! Threshold policy helpers for `/debug/schema` health classification.
//!
//! This module centralizes required-missing thresholds that escalate overall
//! diagnostics health from `degraded` to `unhealthy`.

/// Required missing-table threshold that escalates health to `unhealthy`.
const UNHEALTHY_REQUIRED_MISSING_TABLE_THRESHOLD: usize = 3;
/// Required missing-column threshold that escalates health to `unhealthy`.
const UNHEALTHY_REQUIRED_MISSING_COLUMN_THRESHOLD: usize = 10;

/// Returns whether required-missing counts cross unhealthy escalation thresholds.
pub(super) fn is_unhealthy_by_required_missing_thresholds(
    required_missing_table_count: usize,
    required_missing_column_count: usize,
) -> bool {
    required_missing_table_count >= UNHEALTHY_REQUIRED_MISSING_TABLE_THRESHOLD
        || required_missing_column_count >= UNHEALTHY_REQUIRED_MISSING_COLUMN_THRESHOLD
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    /// Marks threshold as crossed when required missing-table count hits threshold.
    fn threshold_policy_triggers_on_required_missing_table_boundary() {
        assert!(is_unhealthy_by_required_missing_thresholds(3, 0));
    }

    #[test]
    /// Marks threshold as not crossed when required counts are below both thresholds.
    fn threshold_policy_is_not_triggered_below_boundaries() {
        assert!(!is_unhealthy_by_required_missing_thresholds(2, 9));
    }
}