Skip to main content

Mountain/IPC/Common/HealthStatus/
HealthIssue.rs

1#![allow(non_snake_case)]
2
3//! Tagged health issue. Each variant carries a free-form description
4//! string; `Severity` and `Description` accessors normalise the
5//! tag→severity mapping in one place so the recalculation logic in
6//! `HealthMonitor::Struct` stays a pure aggregation.
7
8use serde::{Deserialize, Serialize};
9
10use crate::IPC::Common::HealthStatus::SeverityLevel;
11
12#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
13pub enum Enum {
14	HighLatency(String),
15
16	MemoryPressure(String),
17
18	ConnectionLoss(String),
19
20	QueueOverflow(String),
21
22	SecurityViolation(String),
23
24	PerformanceDegradation(String),
25
26	Custom(String),
27}
28
29impl Enum {
30	pub fn Severity(&self) -> SeverityLevel::Enum {
31		match self {
32			Enum::HighLatency(_) => SeverityLevel::Enum::Medium,
33
34			Enum::MemoryPressure(_) => SeverityLevel::Enum::Medium,
35
36			Enum::ConnectionLoss(_) => SeverityLevel::Enum::High,
37
38			Enum::QueueOverflow(_) => SeverityLevel::Enum::High,
39
40			Enum::SecurityViolation(_) => SeverityLevel::Enum::Critical,
41
42			Enum::PerformanceDegradation(_) => SeverityLevel::Enum::Medium,
43
44			Enum::Custom(_) => SeverityLevel::Enum::Low,
45		}
46	}
47
48	pub fn Description(&self) -> &str {
49		match self {
50			Enum::HighLatency(D)
51			| Enum::MemoryPressure(D)
52			| Enum::ConnectionLoss(D)
53			| Enum::QueueOverflow(D)
54			| Enum::SecurityViolation(D)
55			| Enum::PerformanceDegradation(D)
56			| Enum::Custom(D) => D,
57		}
58	}
59}