Files
node-notifier/src/actors/driving/cron_alerts.rs

22 lines
590 B
Rust

use crate::app::ports::driving::ForMonitoringAlerts;
pub struct CronAlertsActor {
alert_monitor: Box<dyn ForMonitoringAlerts>,
period: std::time::Duration,
}
impl CronAlertsActor {
pub fn new(alert_monitor: Box<dyn ForMonitoringAlerts>, period: std::time::Duration) -> Self {
Self { alert_monitor, period }
}
pub fn start(&mut self) {
loop {
if let Err(e) = self.alert_monitor.alert_on_threshold_violation() {
eprintln!("Error occurred: {}", e);
}
std::thread::sleep(self.period);
}
}
}