Made healthcheck async and repeating and action at config-specified interval
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
use crate::validator::config;
|
||||
use log::debug;
|
||||
use log::{debug, trace};
|
||||
use std::time::Duration;
|
||||
|
||||
pub(crate) struct HealthChecker {
|
||||
@@ -15,10 +15,14 @@ impl HealthChecker {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn run(self) {
|
||||
pub async fn run(self) {
|
||||
debug!(
|
||||
"healthcheck run. will use directory at: {:?} and run every {:?}",
|
||||
self.directory_server, self.interval,
|
||||
)
|
||||
);
|
||||
loop {
|
||||
tokio::time::delay_for(self.interval).await;
|
||||
trace!("going to perform a healthcheck!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use crate::validator::config::Config;
|
||||
use crate::validator::health_check::HealthChecker;
|
||||
use log::debug;
|
||||
use tokio::runtime::Runtime;
|
||||
|
||||
pub mod config;
|
||||
mod health_check;
|
||||
@@ -20,6 +21,11 @@ impl Validator {
|
||||
|
||||
pub fn start(self) {
|
||||
debug!("validator run");
|
||||
self.heath_check.run()
|
||||
|
||||
let mut rt = Runtime::new().unwrap();
|
||||
|
||||
let health_check_future = self.heath_check.run();
|
||||
|
||||
rt.block_on(health_check_future);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user