refactor(app): split service into two funtions
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user