Hide nodes that failed breakers from index page

This commit is contained in:
asonix 2023-07-28 17:46:23 -05:00
parent 60abec2b96
commit 795d3238ad
3 changed files with 9 additions and 1 deletions

View file

@ -93,6 +93,10 @@ impl State {
self.object_cache.write().unwrap().put(object_id, actor_id);
}
pub(crate) fn is_connected(&self, iri: &IriString) -> bool {
self.breakers.should_try(iri)
}
#[tracing::instrument(level = "debug", name = "Building state", skip_all)]
pub(crate) async fn build(db: Db) -> Result<Self, Error> {
let private_key = if let Ok(Some(key)) = db.private_key().await {

View file

@ -39,7 +39,7 @@ impl std::fmt::Debug for Breakers {
}
impl Breakers {
fn should_try(&self, url: &IriString) -> bool {
pub(crate) fn should_try(&self, url: &IriString) -> bool {
if let Some(authority) = url.authority_str() {
if let Some(breaker) = self.inner.get(authority) {
breaker.should_try()

View file

@ -42,6 +42,10 @@ pub(crate) async fn route(
let mut local = Vec::new();
for node in all_nodes {
if !state.is_connected(&node.base) {
continue;
}
if node
.base
.authority_str()