adds name, description; changes critical boolean to severity enum (#855)

This commit is contained in:
Keagan McClelland
2021-11-26 10:29:15 -07:00
committed by Aiden McClelland
parent e5f1c4c955
commit a90c3cb3a1
2 changed files with 12 additions and 3 deletions

View File

@@ -67,11 +67,20 @@ impl HealthChecks {
}
}
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
#[serde(rename_all = "kebab-case")]
pub enum HealthCheckSeverity {
Warning,
Critical,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct HealthCheck {
pub name: String,
pub description: String,
#[serde(flatten)]
implementation: ActionImplementation,
pub critical: bool,
pub severity: HealthCheckSeverity,
pub timeout: Option<Duration>,
}
impl HealthCheck {

View File

@@ -5,7 +5,7 @@ use patch_db::{DbHandle, HasModel};
use serde::{Deserialize, Serialize};
use tracing::instrument;
use self::health_check::HealthCheckId;
use self::health_check::{HealthCheckId, HealthCheckSeverity};
use crate::context::RpcContext;
use crate::dependencies::DependencyErrors;
use crate::notifications::NotificationLevel;
@@ -67,7 +67,7 @@ impl MainStatus {
.health_checks
.0
.get(check)
.map(|hc| hc.critical)
.map(|hc| hc.severity == HealthCheckSeverity::Critical)
.unwrap_or_default() =>
{
ctx.notification_manager.notify(