#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum HealthStatus {
Healthy,
Degraded,
Restricted,
Stopped,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct HealthReport {
pub status: HealthStatus,
pub message: Option<String>,
}
pub trait HealthCheck {
fn name(&self) -> &str;
fn check(&self) -> HealthReport;
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct BasicHealthCheck {
name: String,
report: HealthReport,
}
impl BasicHealthCheck {
pub fn new(name: impl Into<String>, report: HealthReport) -> Self {
Self {
name: name.into(),
report,
}
}
}
impl HealthCheck for BasicHealthCheck {
fn name(&self) -> &str {
&self.name
}
fn check(&self) -> HealthReport {
self.report.clone()
}
}
#[cfg(test)]
#[path = "health_tests.rs"]
mod tests;