Skip to main content

DevelopmentNodeEnvironment_MicrosoftVSCodeDependency_22NodeVersion_Bundle_Clean_Debug_ElectronProfile_EsbuildCompiler_Mountain/IPC/Common/HealthStatus/
HealthIssue.rs

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