refactor(app): split service into two funtions

This commit is contained in:
2025-08-09 22:28:22 +02:00
parent 0564083ac7
commit f3e8b01d7e
2 changed files with 5 additions and 2 deletions

View File

@@ -21,7 +21,7 @@ pub fn new(
} }
impl Service { impl Service {
pub fn run(&self) { pub fn alert_on_threshold_violation(&self) {
// Check for threshold violations and send alerts // 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 {
@@ -30,7 +30,9 @@ impl Service {
.send_notification(&message) .send_notification(&message)
.expect("Failed to send notification"); .expect("Failed to send notification");
} }
}
pub fn send_all_metrics_notification(&self) {
// Send a final notification with all system information // 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 self.notifier

View File

@@ -45,5 +45,6 @@ fn main() {
Box::new(system_monitor_adapter), Box::new(system_monitor_adapter),
Box::new(formatter), Box::new(formatter),
); );
service.run(); service.alert_on_threshold_violation();
service.send_all_metrics_notification();
} }