mirror of
https://forgejo.ellis.link/continuwuation/continuwuity/
synced 2026-08-29 01:18:53 +00:00
feat: Mark servers as online/offline based on transaction responses
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user