forked from mirrors/relay
Hide nodes that failed breakers from index page
This commit is contained in:
parent
60abec2b96
commit
795d3238ad
3 changed files with 9 additions and 1 deletions
|
@ -93,6 +93,10 @@ impl State {
|
||||||
self.object_cache.write().unwrap().put(object_id, actor_id);
|
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)]
|
#[tracing::instrument(level = "debug", name = "Building state", skip_all)]
|
||||||
pub(crate) async fn build(db: Db) -> Result<Self, Error> {
|
pub(crate) async fn build(db: Db) -> Result<Self, Error> {
|
||||||
let private_key = if let Ok(Some(key)) = db.private_key().await {
|
let private_key = if let Ok(Some(key)) = db.private_key().await {
|
||||||
|
|
|
@ -39,7 +39,7 @@ impl std::fmt::Debug for Breakers {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl 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(authority) = url.authority_str() {
|
||||||
if let Some(breaker) = self.inner.get(authority) {
|
if let Some(breaker) = self.inner.get(authority) {
|
||||||
breaker.should_try()
|
breaker.should_try()
|
||||||
|
|
|
@ -42,6 +42,10 @@ pub(crate) async fn route(
|
||||||
let mut local = Vec::new();
|
let mut local = Vec::new();
|
||||||
|
|
||||||
for node in all_nodes {
|
for node in all_nodes {
|
||||||
|
if !state.is_connected(&node.base) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if node
|
if node
|
||||||
.base
|
.base
|
||||||
.authority_str()
|
.authority_str()
|
||||||
|
|
Loading…
Reference in a new issue