fix(healthcheck): do not return true as response if the check if not applicable (#3551)

This commit is contained in:
Kartikeya Hegde
2024-02-13 07:44:18 +00:00
committed by GitHub
parent 02652a2519
commit 6e103cef50
3 changed files with 89 additions and 66 deletions

View File

@ -2,7 +2,8 @@
pub struct RouterHealthCheckResponse {
pub database: bool,
pub redis: bool,
pub locker: bool,
#[serde(skip_serializing_if = "Option::is_none")]
pub vault: Option<bool>,
#[cfg(feature = "olap")]
pub analytics: bool,
pub outgoing_request: bool,
@ -17,4 +18,28 @@ pub struct SchedulerHealthCheckResponse {
pub outgoing_request: bool,
}
pub enum HealthState {
Running,
Error,
NotApplicable,
}
impl From<HealthState> for bool {
fn from(value: HealthState) -> Self {
match value {
HealthState::Running => true,
HealthState::Error | HealthState::NotApplicable => false,
}
}
}
impl From<HealthState> for Option<bool> {
fn from(value: HealthState) -> Self {
match value {
HealthState::Running => Some(true),
HealthState::Error => Some(false),
HealthState::NotApplicable => None,
}
}
}
impl common_utils::events::ApiEventMetric for SchedulerHealthCheckResponse {}