use crate::app::ports::driven::{ ForFormattingMessage, ForMonitoringSystem, ForSendingNotification, }; pub struct Service { notifier: Box, monitor: Box, formatter: Box, } pub fn new( notifier: Box, monitor: Box, formatter: Box, ) -> Service { Service { notifier, monitor, formatter, } } impl Service { pub fn alert_on_threshold_violation(&self) { // Check for threshold violations and send alerts let violations = self.monitor.check_thresholds(); for violation in violations { let message = self.formatter.format_violation(violation); self.notifier .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 .send_notification(&summary) .expect("Failed to send final notification"); } }