feat: Mark servers as online/offline based on transaction responses

This commit is contained in:
timedout
2026-08-11 15:44:11 +01:00
parent 3b69c01b41
commit c022923cfd
2 changed files with 13 additions and 1 deletions
+2
View File
@@ -488,6 +488,8 @@ pub fn hit_unhealthy(&self, server_name: OwnedServerName) {
///
/// TODO: flush senders too
pub fn mark_healthy(&self, server_name: &ServerName) {
// TODO: We need to make sure the sender flush DOESN'T trigger if this is called
// by the senders themselves.
let mut map = self.remote_health.write();
map.remove(server_name);
}
+11 -1
View File
@@ -142,7 +142,14 @@ async fn handle_response<'a>(
) {
match response {
| Ok(dest) => self.handle_response_ok(&dest, futures, statuses).await,
| Err((dest, e)) => Self::handle_response_err(dest, statuses, &e),
| Err((dest, e)) => {
if e.status_code().is_server_error()
&& let Destination::Federation(dest) = &dest
{
self.hit_unhealthy(dest.clone());
}
Self::handle_response_err(dest, statuses, &e);
},
}
}
@@ -171,6 +178,9 @@ async fn handle_response_ok<'a>(
) {
let _cork = self.db.db.cork();
self.db.delete_all_active_requests_for(dest).await;
if let Destination::Federation(server_name) = dest {
self.mark_healthy(server_name);
}
// Find events that have been added since starting the last request
let new_events = self