diff --git a/src/events.rs b/src/events.rs index 780fee9..df3a0f7 100644 --- a/src/events.rs +++ b/src/events.rs @@ -73,7 +73,6 @@ impl Handler for EventBroker { type Result = (); fn handle(&mut self, msg: Event, _ctx: &mut Self::Context) -> Self::Result { - tracing::info!("Event received"); for (_, ses) in self.sessions.iter() { let _ = ses.addr.do_send(msg.clone()); } diff --git a/src/main.rs b/src/main.rs index 0e9fca5..1b0904a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -99,13 +99,21 @@ async fn main() { .await { Ok(res) if res.status() == 200 => { - st.healthcheck_status.lock().await.insert(app.id, true); - let _ = events::EventBroker::from_registry() - .send(events::Event::HealthcheckChange { - app_id: app.id, - alive: true, - }) - .await; + if !st + .healthcheck_status + .lock() + .await + .get(&app.id) + .unwrap_or(&false) + { + st.healthcheck_status.lock().await.insert(app.id, true); + let _ = events::EventBroker::from_registry() + .send(events::Event::HealthcheckChange { + app_id: app.id, + alive: true, + }) + .await; + } } Err(e) => { tracing::warn!("Error performing healthcheck: {}", e); @@ -118,14 +126,22 @@ async fn main() { .await; } Ok(res) => { - tracing::warn!("Non 200 status code: {}", res.status()); - st.healthcheck_status.lock().await.insert(app.id, false); - let _ = events::EventBroker::from_registry() - .send(events::Event::HealthcheckChange { - app_id: app.id, - alive: false, - }) - .await; + if st + .healthcheck_status + .lock() + .await + .get(&app.id) + .unwrap_or(&true) + { + tracing::warn!("Non 200 status code: {}", res.status()); + st.healthcheck_status.lock().await.insert(app.id, false); + let _ = events::EventBroker::from_registry() + .send(events::Event::HealthcheckChange { + app_id: app.id, + alive: false, + }) + .await; + } } } }