feat: implement driving cron actor

This commit is contained in:
2025-08-10 17:41:10 +02:00
parent 91c5209266
commit fd9a1114b9
6 changed files with 66 additions and 10 deletions

View File

@@ -0,0 +1,21 @@
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(&self) {
loop {
if let Err(e) = self.alert_monitor.alert_on_threshold_violation() {
eprintln!("Error occurred: {}", e);
}
std::thread::sleep(self.period);
}
}
}