feat: implement driving cron actor
This commit is contained in:
21
src/actors/driving/cron_alerts.rs
Normal file
21
src/actors/driving/cron_alerts.rs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user