Client using pre-filtered topology for the healthchecker
This commit is contained in:
Generated
+2
@@ -1422,6 +1422,7 @@ dependencies = [
|
||||
"built",
|
||||
"clap",
|
||||
"crypto",
|
||||
"directory-client",
|
||||
"dotenv",
|
||||
"futures 0.3.1",
|
||||
"healthcheck",
|
||||
@@ -1431,6 +1432,7 @@ dependencies = [
|
||||
"serde_derive",
|
||||
"tokio 0.2.10",
|
||||
"toml",
|
||||
"topology",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
@@ -43,17 +43,8 @@ where
|
||||
refresh_rate: f64,
|
||||
identity_keypair: IDPair,
|
||||
) -> Self {
|
||||
// topology control run a healthcheck to determine healthy-ish nodes:
|
||||
// this is a temporary solution as the healthcheck will eventually be moved to validators
|
||||
|
||||
let healthcheck_config = healthcheck::config::HealthCheck {
|
||||
directory_server: directory_server.clone(),
|
||||
// those are literally irrelevant when running single check
|
||||
interval: 100000.0,
|
||||
resolution_timeout: 5.0,
|
||||
num_test_packets: 2,
|
||||
};
|
||||
let health_checker = healthcheck::HealthChecker::new(healthcheck_config, identity_keypair);
|
||||
let health_checker = healthcheck::HealthChecker::new(5.0, 2, identity_keypair);
|
||||
|
||||
let mut topology_control = TopologyControl {
|
||||
directory_server,
|
||||
@@ -79,8 +70,16 @@ where
|
||||
|
||||
async fn get_current_compatible_topology(&self) -> Result<T, TopologyError> {
|
||||
let full_topology = T::new(self.directory_server.clone());
|
||||
let version_filtered_topology = full_topology.filter_node_versions(
|
||||
built_info::PKG_VERSION,
|
||||
built_info::PKG_VERSION,
|
||||
built_info::PKG_VERSION,
|
||||
);
|
||||
|
||||
let healthcheck_result = self.health_checker.do_check().await;
|
||||
let healthcheck_result = self
|
||||
.health_checker
|
||||
.do_check(&version_filtered_topology)
|
||||
.await;
|
||||
let healthcheck_scores = match healthcheck_result {
|
||||
Err(err) => {
|
||||
error!("Error while performing the healthcheck: {:?}", err);
|
||||
@@ -89,21 +88,15 @@ where
|
||||
Ok(scores) => scores,
|
||||
};
|
||||
|
||||
let healthy_topology =
|
||||
healthcheck_scores.filter_topology_by_score(&full_topology, NODE_HEALTH_THRESHOLD);
|
||||
|
||||
let versioned_healthy_topology = healthy_topology.filter_node_versions(
|
||||
built_info::PKG_VERSION,
|
||||
built_info::PKG_VERSION,
|
||||
built_info::PKG_VERSION,
|
||||
);
|
||||
let healthy_topology = healthcheck_scores
|
||||
.filter_topology_by_score(&version_filtered_topology, NODE_HEALTH_THRESHOLD);
|
||||
|
||||
// make sure you can still send a packet through the network:
|
||||
if !versioned_healthy_topology.can_construct_path_through() {
|
||||
if !healthy_topology.can_construct_path_through() {
|
||||
return Err(TopologyError::NoValidPathsError);
|
||||
}
|
||||
|
||||
Ok(versioned_healthy_topology)
|
||||
Ok(healthy_topology)
|
||||
}
|
||||
|
||||
pub(crate) fn get_inner_ref(&self) -> Arc<FRwLock<Inner<T>>> {
|
||||
|
||||
@@ -21,7 +21,9 @@ toml = "0.5.5"
|
||||
|
||||
## internal
|
||||
crypto = {path = "../common/crypto"}
|
||||
directory-client = { path = "../common/clients/directory-client" }
|
||||
healthcheck = {path = "../common/healthcheck" }
|
||||
topology = {path = "../common/topology"}
|
||||
|
||||
[build-dependencies]
|
||||
built = "0.3.2"
|
||||
|
||||
Reference in New Issue
Block a user