diff --git a/Cargo.toml b/Cargo.toml index 361e0d5..53a830f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "beamctl" -version = "0.3.0" +version = "0.4.0" edition = "2021" repository = "https://github.com/samply/beamctl" documentation = "https://github.com/samply/beamctl" diff --git a/src/proxy_health.rs b/src/proxy_health.rs index 7a9d9c1..2ace129 100644 --- a/src/proxy_health.rs +++ b/src/proxy_health.rs @@ -8,7 +8,7 @@ use crate::icinga::IcingaCode; #[derive(Debug, Clone, Serialize, Deserialize)] pub struct ProxyStatus { - last_active: SystemTime + last_disconnect: Option, } pub async fn query_proxy_health(proxy_name: &str, api_key: &str, broker_url: &Url) -> Result { @@ -29,7 +29,10 @@ pub async fn query_proxy_health(proxy_name: &str, api_key: &str, broker_url: &Ur let Ok(status) = res.json::().await else { return Err(anyhow!("Got status 503 from broker without a proxy status!")); }; - let last_report_dur = status.last_active.elapsed().unwrap(); + let last_report_dur = status.last_disconnect + .expect("This field should always exist, since we got code 503") + .elapsed() + .expect("Error: Check system time."); let minutes = last_report_dur.as_secs() / 60; let seconds = last_report_dur.as_secs() % 60; println!("Beam.Proxy unavailable: last report was {minutes}m and {seconds}s ago!");