Add html page
This commit is contained in:
@ -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);
|
||||
|
||||
Reference in New Issue
Block a user