Temporarily moved healthcheck from validator to separate common crate

This commit is contained in:
Jedrzej Stuczynski
2020-01-14 10:44:05 +00:00
parent 6fbc6c6680
commit 315ece38ae
11 changed files with 75 additions and 43 deletions
Generated
+21 -9
View File
@@ -845,6 +845,26 @@ dependencies = [
"tokio-io",
]
[[package]]
name = "healthcheck"
version = "0.1.0"
dependencies = [
"addressing",
"crypto",
"directory-client",
"futures 0.3.1",
"itertools",
"log",
"mix-client",
"provider-client",
"serde",
"serde_derive",
"sfw-provider-requests",
"sphinx",
"tokio 0.2.9",
"topology",
]
[[package]]
name = "hermit-abi"
version = "0.1.6"
@@ -1390,25 +1410,17 @@ dependencies = [
name = "nym-validator"
version = "0.1.0"
dependencies = [
"addressing",
"built",
"clap",
"crypto",
"directory-client",
"dotenv",
"futures 0.3.1",
"itertools",
"healthcheck",
"log",
"mix-client",
"pretty_env_logger",
"provider-client",
"serde",
"serde_derive",
"sfw-provider-requests",
"sphinx",
"tokio 0.2.9",
"toml",
"topology",
]
[[package]]
+1
View File
@@ -7,6 +7,7 @@ members = [
"common/clients/validator-client",
"common/addressing",
"common/crypto",
"common/healthcheck",
"common/topology",
"mixnode",
"nym-client",
+29
View File
@@ -0,0 +1,29 @@
[package]
name = "healthcheck"
version = "0.1.0"
authors = ["Jedrzej Stuczynski <andrew@nymtech.net>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
futures = "0.3.1"
itertools = "0.8.2"
log = "0.4.8"
serde = "1.0.104"
serde_derive = "1.0.104"
tokio = { version = "0.2", features = ["full"] }
## internal
addressing = {path = "../addressing" }
crypto = { path = "../crypto" }
directory-client = { path = "../clients/directory-client" }
mix-client = { path = "../clients/mix-client" }
provider-client = { path = "../clients/provider-client" }
sfw-provider-requests = { path = "../../sfw-provider/sfw-provider-requests" }
topology = {path = "../topology" }
## will be moved to proper dependencies once released
sphinx = { git = "https://github.com/nymtech/sphinx", rev="1d8cefcb6a0cb8e87d00d89eb1ccf2839e92aa1f" }
[dev-dependencies]
+15
View File
@@ -0,0 +1,15 @@
use serde_derive::Deserialize;
#[derive(Deserialize, Debug)]
pub struct HealthCheck {
#[serde(rename(deserialize = "directory-server"))]
pub directory_server: String,
pub interval: f64, // in seconds
#[serde(rename(deserialize = "resolution-timeout"))]
pub resolution_timeout: f64, // in seconds
#[serde(rename(deserialize = "test-packets-per-node"))]
pub num_test_packets: usize,
}
@@ -1,11 +1,11 @@
use crate::validator::config;
use crate::validator::health_check::result::HealthCheckResult;
use crate::result::HealthCheckResult;
use directory_client::requests::presence_topology_get::PresenceTopologyGetRequester;
use directory_client::DirectoryClient;
use log::{debug, error, info, trace};
use std::time::Duration;
use topology::NymTopologyError;
pub mod config;
mod path_check;
mod result;
mod score;
@@ -23,7 +23,7 @@ impl From<topology::NymTopologyError> for HealthCheckerError {
}
}
pub(crate) struct HealthChecker {
pub struct HealthChecker {
directory_client: directory_client::Client,
interval: Duration,
num_test_packets: usize,
@@ -61,7 +61,7 @@ impl HealthChecker {
self.num_test_packets,
self.resolution_timeout,
)
.await;
.await;
healthcheck_result.sort_scores();
Ok(healthcheck_result)
}
@@ -1,5 +1,5 @@
use crate::validator::health_check::path_check::{PathChecker, PathStatus};
use crate::validator::health_check::score::NodeScore;
use crate::path_check::{PathChecker, PathStatus};
use crate::score::NodeScore;
use crypto::identity::{DummyMixIdentityKeyPair, MixnetIdentityKeyPair};
use log::{debug, info, warn};
use std::collections::HashMap;
+1 -11
View File
@@ -12,7 +12,6 @@ clap = "2.33.0"
# Read notes https://crates.io/crates/dotenv - tl;dr: don't use in production, set environmental variables properly.
dotenv = "0.15.0"
futures = "0.3.1"
itertools = "0.8.2"
log = "0.4.8"
pretty_env_logger = "0.3.1"
serde = "1.0.104"
@@ -21,16 +20,7 @@ tokio = { version = "0.2", features = ["full"] }
toml = "0.5.5"
## internal
addressing = {path = "../common/addressing" }
crypto = { path = "../common/crypto" }
directory-client = { path = "../common/clients/directory-client" }
mix-client = { path = "../common/clients/mix-client" }
provider-client = { path = "../common/clients/provider-client" }
sfw-provider-requests = { path = "../sfw-provider/sfw-provider-requests" }
topology = {path = "../common/topology" }
## will be moved to proper dependencies once released
sphinx = { git = "https://github.com/nymtech/sphinx", rev="1d8cefcb6a0cb8e87d00d89eb1ccf2839e92aa1f" }
healthcheck = {path = "../common/healthcheck" }
[build-dependencies]
built = "0.3.2"
+1 -15
View File
@@ -3,19 +3,5 @@ use serde_derive::Deserialize;
#[derive(Deserialize, Debug)]
pub struct Config {
#[serde(rename(deserialize = "healthcheck"))]
pub health_check: HealthCheck,
}
#[derive(Deserialize, Debug)]
pub struct HealthCheck {
#[serde(rename(deserialize = "directory-server"))]
pub directory_server: String,
pub interval: f64, // in seconds
#[serde(rename(deserialize = "resolution-timeout"))]
pub resolution_timeout: f64, // in seconds
#[serde(rename(deserialize = "test-packets-per-node"))]
pub num_test_packets: usize,
pub health_check: healthcheck::config::HealthCheck,
}
+1 -2
View File
@@ -1,10 +1,9 @@
use crate::validator::config::Config;
use crate::validator::health_check::HealthChecker;
use healthcheck::HealthChecker;
use log::debug;
use tokio::runtime::Runtime;
pub mod config;
mod health_check;
pub struct Validator {
heath_check: HealthChecker,