Add html page

This commit is contained in:
2021-01-31 01:42:39 +01:00
parent e491d4aff6
commit 36834dd5fd
6 changed files with 144 additions and 14 deletions

View File

@ -31,18 +31,24 @@ pub enum HttpHealthCheckMode {
}
pub struct HealthState {
pub last_update: Mutex<Option<DateTime<Utc>>>,
pub health: HashMap<ServiceId, Mutex<Option<HealthStatus>>>,
pub config: HealthConfig,
}
#[derive(Serialize, Deserialize)]
pub struct HealthConfig {
/// The time between updates (in seconds)
pub update_period: u64,
/// The list of services
pub services: HashMap<ServiceId, ServiceConfig>,
}
impl HealthState {
pub fn new(config: HealthConfig) -> HealthState {
HealthState {
last_update: Mutex::new(None),
health: config
.services
.iter()
@ -53,6 +59,8 @@ impl HealthState {
}
pub async fn update(&self) {
*self.last_update.lock().await = Some(Utc::now());
for (id, status) in &self.health {
let url = &self.config.services[id].url;
info!("service [{}] querying {}", id, url);