From f3e8b01d7e525530c32cfce711b8120d4067e87a Mon Sep 17 00:00:00 2001 From: JeremyLARDENOIS Date: Sat, 9 Aug 2025 22:28:22 +0200 Subject: [PATCH] refactor(app): split service into two funtions --- src/app/service.rs | 4 +++- src/main.rs | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/app/service.rs b/src/app/service.rs index 4f390b8..114fff2 100644 --- a/src/app/service.rs +++ b/src/app/service.rs @@ -21,7 +21,7 @@ pub fn new( } impl Service { - pub fn run(&self) { + pub fn alert_on_threshold_violation(&self) { // Check for threshold violations and send alerts let violations = self.monitor.check_thresholds(); for violation in violations { @@ -30,7 +30,9 @@ impl Service { .send_notification(&message) .expect("Failed to send notification"); } + } + pub fn send_all_metrics_notification(&self) { // Send a final notification with all system information let summary = self.formatter.format_summary(&self.monitor.get_metrics()); self.notifier diff --git a/src/main.rs b/src/main.rs index aa441ac..852922a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -45,5 +45,6 @@ fn main() { Box::new(system_monitor_adapter), Box::new(formatter), ); - service.run(); + service.alert_on_threshold_violation(); + service.send_all_metrics_notification(); }