refactor(service): remove useless comments
This commit is contained in:
@@ -21,8 +21,8 @@ pub fn new(
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Service {
|
impl Service {
|
||||||
|
/// Check for threshold violations and send alerts
|
||||||
pub fn alert_on_threshold_violation(&self) -> Result<(), Box<dyn std::error::Error>> {
|
pub fn alert_on_threshold_violation(&self) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
// Check for threshold violations and send alerts
|
|
||||||
let violations = self.monitor.check_thresholds();
|
let violations = self.monitor.check_thresholds();
|
||||||
for violation in violations {
|
for violation in violations {
|
||||||
let message = self.formatter.format_violation(violation);
|
let message = self.formatter.format_violation(violation);
|
||||||
@@ -32,8 +32,8 @@ impl Service {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Send a final notification with all system information
|
||||||
pub fn send_all_metrics_notification(&self) -> Result<(), Box<dyn std::error::Error>> {
|
pub fn send_all_metrics_notification(&self) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
// Send a final notification with all system information
|
|
||||||
let summary = self.formatter.format_summary(&self.monitor.get_metrics());
|
let summary = self.formatter.format_summary(&self.monitor.get_metrics());
|
||||||
self.notifier.send_notification(&summary)?;
|
self.notifier.send_notification(&summary)?;
|
||||||
|
|
||||||
@@ -56,7 +56,6 @@ mod tests {
|
|||||||
let mut monitor = MockForMonitoringSystem::new();
|
let mut monitor = MockForMonitoringSystem::new();
|
||||||
let mut formatter = MockForFormattingMessage::new();
|
let mut formatter = MockForFormattingMessage::new();
|
||||||
|
|
||||||
// Set up expectations for the mocks
|
|
||||||
notifier.expect_send_notification().returning(|_| Ok(()));
|
notifier.expect_send_notification().returning(|_| Ok(()));
|
||||||
monitor.expect_check_thresholds().returning(|| vec![]);
|
monitor.expect_check_thresholds().returning(|| vec![]);
|
||||||
monitor.expect_get_metrics().returning(|| HashMap::new());
|
monitor.expect_get_metrics().returning(|| HashMap::new());
|
||||||
@@ -78,7 +77,6 @@ mod tests {
|
|||||||
let mut monitor = MockForMonitoringSystem::new();
|
let mut monitor = MockForMonitoringSystem::new();
|
||||||
let mut formatter = MockForFormattingMessage::new();
|
let mut formatter = MockForFormattingMessage::new();
|
||||||
|
|
||||||
// Set up expectations for the mocks
|
|
||||||
notifier.expect_send_notification().returning(|_| Ok(()));
|
notifier.expect_send_notification().returning(|_| Ok(()));
|
||||||
monitor.expect_check_thresholds().returning(|| vec![]);
|
monitor.expect_check_thresholds().returning(|| vec![]);
|
||||||
monitor.expect_get_metrics().returning(|| HashMap::new());
|
monitor.expect_get_metrics().returning(|| HashMap::new());
|
||||||
@@ -100,13 +98,11 @@ mod tests {
|
|||||||
let mut monitor = MockForMonitoringSystem::new();
|
let mut monitor = MockForMonitoringSystem::new();
|
||||||
let mut formatter = MockForFormattingMessage::new();
|
let mut formatter = MockForFormattingMessage::new();
|
||||||
|
|
||||||
// Mock a single violation to trigger notification
|
|
||||||
monitor.expect_check_thresholds().returning(|| {
|
monitor.expect_check_thresholds().returning(|| {
|
||||||
vec![Box::new(crate::app::ports::driven::MockForGettingViolationData::new())]
|
vec![Box::new(crate::app::ports::driven::MockForGettingViolationData::new())]
|
||||||
});
|
});
|
||||||
formatter.expect_format_violation().returning(|_| "Test violation".to_string());
|
formatter.expect_format_violation().returning(|_| "Test violation".to_string());
|
||||||
|
|
||||||
// Mock notification failure
|
|
||||||
notifier.expect_send_notification()
|
notifier.expect_send_notification()
|
||||||
.returning(|_| Err("Network error".into()));
|
.returning(|_| Err("Network error".into()));
|
||||||
|
|
||||||
@@ -128,7 +124,6 @@ mod tests {
|
|||||||
monitor.expect_get_metrics().returning(|| HashMap::new());
|
monitor.expect_get_metrics().returning(|| HashMap::new());
|
||||||
formatter.expect_format_summary().returning(|_| "Test summary".to_string());
|
formatter.expect_format_summary().returning(|_| "Test summary".to_string());
|
||||||
|
|
||||||
// Mock notification failure
|
|
||||||
notifier.expect_send_notification()
|
notifier.expect_send_notification()
|
||||||
.returning(|_| Err("Network error".into()));
|
.returning(|_| Err("Network error".into()));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user