Dont reepat healthcheck statuses
Only sends healthcheck statuses if they are different then the current value
This commit is contained in:
parent
04c2f37b60
commit
6d9d863039
|
@ -73,7 +73,6 @@ impl Handler<Event> 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());
|
||||
}
|
||||
|
|
16
src/main.rs
16
src/main.rs
|
@ -99,6 +99,13 @@ async fn main() {
|
|||
.await
|
||||
{
|
||||
Ok(res) if res.status() == 200 => {
|
||||
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 {
|
||||
|
@ -107,6 +114,7 @@ async fn main() {
|
|||
})
|
||||
.await;
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
tracing::warn!("Error performing healthcheck: {}", e);
|
||||
st.healthcheck_status.lock().await.insert(app.id, false);
|
||||
|
@ -118,6 +126,13 @@ async fn main() {
|
|||
.await;
|
||||
}
|
||||
Ok(res) => {
|
||||
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()
|
||||
|
@ -129,6 +144,7 @@ async fn main() {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
tokio::time::sleep(tokio::time::Duration::from_secs(60)).await;
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue