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 = ();
|
type Result = ();
|
||||||
|
|
||||||
fn handle(&mut self, msg: Event, _ctx: &mut Self::Context) -> Self::Result {
|
fn handle(&mut self, msg: Event, _ctx: &mut Self::Context) -> Self::Result {
|
||||||
tracing::info!("Event received");
|
|
||||||
for (_, ses) in self.sessions.iter() {
|
for (_, ses) in self.sessions.iter() {
|
||||||
let _ = ses.addr.do_send(msg.clone());
|
let _ = ses.addr.do_send(msg.clone());
|
||||||
}
|
}
|
||||||
|
|
46
src/main.rs
46
src/main.rs
|
@ -99,13 +99,21 @@ async fn main() {
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
Ok(res) if res.status() == 200 => {
|
Ok(res) if res.status() == 200 => {
|
||||||
st.healthcheck_status.lock().await.insert(app.id, true);
|
if !st
|
||||||
let _ = events::EventBroker::from_registry()
|
.healthcheck_status
|
||||||
.send(events::Event::HealthcheckChange {
|
.lock()
|
||||||
app_id: app.id,
|
.await
|
||||||
alive: true,
|
.get(&app.id)
|
||||||
})
|
.unwrap_or(&false)
|
||||||
.await;
|
{
|
||||||
|
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) => {
|
Err(e) => {
|
||||||
tracing::warn!("Error performing healthcheck: {}", e);
|
tracing::warn!("Error performing healthcheck: {}", e);
|
||||||
|
@ -118,14 +126,22 @@ async fn main() {
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
Ok(res) => {
|
Ok(res) => {
|
||||||
tracing::warn!("Non 200 status code: {}", res.status());
|
if st
|
||||||
st.healthcheck_status.lock().await.insert(app.id, false);
|
.healthcheck_status
|
||||||
let _ = events::EventBroker::from_registry()
|
.lock()
|
||||||
.send(events::Event::HealthcheckChange {
|
.await
|
||||||
app_id: app.id,
|
.get(&app.id)
|
||||||
alive: false,
|
.unwrap_or(&true)
|
||||||
})
|
{
|
||||||
.await;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue