Skip to content

Commit

Permalink
fix: fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolay-komarevskiy committed Jun 25, 2024
1 parent a44805a commit 8b99ff6
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ use url::Url;

use crate::{
agent::http_transport::{
api_nodes_dynamic_routing::{
dynamic_routing::{
health_check::HealthManagerActor, messages::FetchedNodes, nodes_fetch::NodesFetchActor,
},
route_provider::RouteProvider,
},
AgentError,
};

use super::{
use crate::agent::http_transport::dynamic_routing::{
health_check::{HealthCheck, HealthChecker},
node::Node,
nodes_fetch::{Fetch, NodesFetcher},
Expand Down Expand Up @@ -201,18 +201,17 @@ where

#[cfg(test)]
mod tests {
use anyhow::anyhow;
use reqwest::Client;
use std::{
sync::{Arc, Once},
time::Duration,
};
use tracing::{info, Level};
use tracing::Level;
use tracing_subscriber::FmtSubscriber;

use crate::{
agent::http_transport::{
api_nodes_dynamic_routing::{
dynamic_routing::{
dynamic_route_provider::{DynamicRouteProvider, IC0_SEED_DOMAIN},
health_check::HealthCheck,
node::Node,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
use anyhow::{anyhow, bail};
use arc_swap::ArcSwap;
use anyhow::bail;
use async_trait::async_trait;
use http::{Method, StatusCode};
use reqwest::{Client, Request};
use std::{
collections::HashMap,
fmt::Debug,
sync::Arc,
time::{Duration, Instant},
Expand All @@ -14,13 +12,13 @@ use tokio_util::{sync::CancellationToken, task::TaskTracker};
use tracing::{debug, error, info, warn};
use url::Url;

use super::{
use crate::agent::http_transport::dynamic_routing::{
messages::{FetchedNodes, NodeHealthState},
node::Node,
type_aliases::{GlobalShared, ReceiverMpsc, ReceiverWatch, SenderMpsc},
};

use crate::agent::http_transport::api_nodes_dynamic_routing::snapshot::snapshot::RoutingSnapshot;
use crate::agent::http_transport::dynamic_routing::snapshot::snapshot::RoutingSnapshot;

const CHANNEL_BUFFER: usize = 128;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::{health_check::HealthCheckStatus, node::Node};
use crate::agent::http_transport::dynamic_routing::{health_check::HealthCheckStatus, node::Node};

#[derive(Debug, Clone)]
pub struct FetchedNodes {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
use crate::{agent::http_transport::ReqwestTransport, Agent};
use anyhow::{anyhow, bail, Context, Error};
use arc_swap::ArcSwap;
use anyhow::Context;
use async_trait::async_trait;
use candid::Principal;
use reqwest::Client;
use std::{fmt::Debug, sync::Arc, time::Duration};
use tokio::time::{self, sleep};
use tokio_util::sync::CancellationToken;
use tracing::{error, info, warn};
use tracing::{error, warn};
use url::Url;

use super::{
use crate::agent::http_transport::dynamic_routing::health_check::HEALTH_MANAGER_ACTOR;
use crate::agent::http_transport::dynamic_routing::snapshot::snapshot::RoutingSnapshot;
use crate::agent::http_transport::dynamic_routing::{
messages::FetchedNodes,
node::Node,
type_aliases::{GlobalShared, SenderWatch},
};
use crate::agent::http_transport::api_nodes_dynamic_routing::snapshot::snapshot::RoutingSnapshot;
use crate::agent::http_transport::api_nodes_dynamic_routing::health_check::HEALTH_MANAGER_ACTOR;
const NODES_FETCH_ACTOR: &str = "NodesFetchActor";

#[async_trait]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ use std::{collections::HashSet, time::Duration};
use rand::Rng;
use simple_moving_average::{SumTreeSMA, SMA};

use crate::agent::http_transport::api_nodes_dynamic_routing::{
health_check::HealthCheckStatus, node::Node,
};
use crate::agent::http_transport::dynamic_routing::{health_check::HealthCheckStatus, node::Node};

use crate::agent::http_transport::api_nodes_dynamic_routing::snapshot::snapshot::RoutingSnapshot;
use crate::agent::http_transport::dynamic_routing::snapshot::snapshot::RoutingSnapshot;

// Some big value implying that node is unhealthy, should be much bigger than node's latency.
const MAX_LATENCY: Duration = Duration::from_secs(500);
Expand Down Expand Up @@ -136,7 +134,7 @@ mod tests {

use simple_moving_average::SMA;

use crate::agent::http_transport::api_nodes_dynamic_routing::{
use crate::agent::http_transport::dynamic_routing::{
health_check::HealthCheckStatus,
node::Node,
snapshot::{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::{
},
};

use crate::agent::http_transport::api_nodes_dynamic_routing::{
use crate::agent::http_transport::dynamic_routing::{
health_check::HealthCheckStatus, node::Node, snapshot::snapshot::RoutingSnapshot,
};

Expand Down Expand Up @@ -85,11 +85,11 @@ mod tests {
use std::time::Duration;
use std::{collections::HashSet, sync::atomic::Ordering};

use crate::agent::http_transport::api_nodes_dynamic_routing::health_check::HealthCheckStatus;
use crate::agent::http_transport::api_nodes_dynamic_routing::node::Node;
use crate::agent::http_transport::api_nodes_dynamic_routing::snapshot::snapshot::RoutingSnapshot;

use super::RoundRobinRoutingSnapshot;
use crate::agent::http_transport::dynamic_routing::{
health_check::HealthCheckStatus,
node::Node,
snapshot::snapshot::{RoundRobinRoutingSnapshot, RoutingSnapshot},
};

#[test]
fn test_snapshot_init() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use std::fmt::Debug;

use crate::agent::http_transport::api_nodes_dynamic_routing::{
health_check::HealthCheckStatus, node::Node,
};
use crate::agent::http_transport::dynamic_routing::{health_check::HealthCheckStatus, node::Node};

pub trait RoutingSnapshot: Send + Sync + Clone + Debug {
fn has_nodes(&self) -> bool;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ use arc_swap::ArcSwap;
use async_trait::async_trait;
use url::Url;

use crate::agent::http_transport::dynamic_routing::{
health_check::{HealthCheck, HealthCheckStatus},
node::Node,
nodes_fetch::Fetch,
type_aliases::GlobalShared,
};
use crate::agent::http_transport::route_provider::RouteProvider;

use super::health_check::{HealthCheck, HealthCheckStatus};
use super::node::Node;
use super::nodes_fetch::Fetch;
use super::type_aliases::GlobalShared;

pub fn route_n_times(n: usize, f: Arc<impl RouteProvider>) -> Vec<String> {
(0..n)
.map(|_| f.route().unwrap().domain().unwrap().to_string())
Expand Down
2 changes: 1 addition & 1 deletion ic-agent/src/agent/http_transport/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ const ICP0_SUB_DOMAIN: &str = ".icp0.io";
const ICP_API_SUB_DOMAIN: &str = ".icp-api.io";
#[allow(dead_code)]
const LOCALHOST_SUB_DOMAIN: &str = ".localhost";
pub mod api_nodes_dynamic_routing;
pub mod dynamic_routing;
pub mod route_provider;

0 comments on commit 8b99ff6

Please sign in to comment.