Skip to content

Commit

Permalink
chore: reduce public APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolay-komarevskiy committed Jul 17, 2024
1 parent df7b557 commit 38a8b45
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,12 @@ impl HealthCheckActor {
}

/// The name of the health manager actor.
pub const HEALTH_MANAGER_ACTOR: &str = "HealthManagerActor";
pub(super) const HEALTH_MANAGER_ACTOR: &str = "HealthManagerActor";

/// A struct managing the health checks of the nodes.
/// It receives the fetched nodes from the `NodesFetchActor` and starts the health checks for them.
/// It also receives the health status of the nodes from the `HealthCheckActor/s` and updates the routing snapshot.
pub struct HealthManagerActor<S> {
pub(super) struct HealthManagerActor<S> {
/// The health checker.
checker: Arc<dyn HealthCheck>,
/// The period of the health check.
Expand Down
6 changes: 3 additions & 3 deletions ic-agent/src/agent/http_transport/dynamic_routing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ pub mod dynamic_route_provider;
/// Health check implementation.
pub mod health_check;
/// Messages used in dynamic routing.
pub mod messages;
pub(super) mod messages;
/// Node implementation.
pub mod node;
/// Nodes fetch implementation.
pub mod nodes_fetch;
/// Routing snapshot implementation.
pub mod snapshot;
#[cfg(test)]
pub mod test_utils;
pub(super) mod test_utils;
/// Type aliases used in dynamic routing.
pub mod type_aliases;
pub(super) mod type_aliases;
9 changes: 5 additions & 4 deletions ic-agent/src/agent/http_transport/dynamic_routing/node.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use url::Url;

use crate::agent::ApiBoundaryNode;

use super::dynamic_route_provider::DynamicRouteProviderError;
use crate::agent::{
http_transport::dynamic_routing::dynamic_route_provider::DynamicRouteProviderError,
ApiBoundaryNode,
};

/// Represents a node in the dynamic routing.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
Expand Down Expand Up @@ -52,7 +53,7 @@ impl TryFrom<&ApiBoundaryNode> for Node {
}

/// Checks if the given domain is a valid URL.
pub fn is_valid_domain<S: AsRef<str>>(domain: S) -> bool {
fn is_valid_domain<S: AsRef<str>>(domain: S) -> bool {
// Prepend scheme to make it a valid URL
let url_string = format!("http://{}", domain.as_ref());
Url::parse(&url_string).is_ok()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl Fetch for NodesFetcher {
}

/// A struct representing the actor responsible for fetching existing nodes and communicating it with the listener.
pub struct NodesFetchActor<S> {
pub(super) struct NodesFetchActor<S> {
/// The fetcher object responsible for fetching the nodes.
fetcher: Arc<dyn Fetch>,
/// Time period between fetches.
Expand Down
13 changes: 8 additions & 5 deletions ic-agent/src/agent/http_transport/dynamic_routing/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,17 @@ use crate::agent::http_transport::{
route_provider::RouteProvider,
};

pub fn route_n_times(n: usize, f: Arc<impl RouteProvider + ?Sized>) -> Vec<String> {
pub(super) fn route_n_times(n: usize, f: Arc<impl RouteProvider + ?Sized>) -> Vec<String> {
(0..n)
.map(|_| f.route().unwrap().domain().unwrap().to_string())
.collect()
}

pub fn assert_routed_domains<T>(actual: Vec<T>, expected: Vec<T>, expected_repetitions: usize)
where
pub(super) fn assert_routed_domains<T>(
actual: Vec<T>,
expected: Vec<T>,
expected_repetitions: usize,
) where
T: AsRef<str> + Eq + Hash + Debug + Ord,
{
fn build_count_map<T>(items: &[T]) -> HashMap<&T, usize>
Expand Down Expand Up @@ -54,7 +57,7 @@ where
}

#[derive(Debug)]
pub struct NodesFetcherMock {
pub(super) struct NodesFetcherMock {
// A set of nodes, existing in the topology.
pub nodes: AtomicSwap<Vec<Node>>,
}
Expand Down Expand Up @@ -86,7 +89,7 @@ impl NodesFetcherMock {
}

#[derive(Debug)]
pub struct NodeHealthCheckerMock {
pub(super) struct NodeHealthCheckerMock {
healthy_nodes: Arc<ArcSwap<HashSet<Node>>>,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ use std::sync::Arc;
use tokio::sync::{mpsc, watch};

/// A type alias for the sender end of a watch channel.
pub type SenderWatch<T> = watch::Sender<Option<T>>;
pub(super) type SenderWatch<T> = watch::Sender<Option<T>>;

/// A type alias for the receiver end of a watch channel.
pub type ReceiverWatch<T> = watch::Receiver<Option<T>>;
pub(super) type ReceiverWatch<T> = watch::Receiver<Option<T>>;

/// A type alias for the sender end of a multi-producer, single-consumer channel.
pub type SenderMpsc<T> = mpsc::Sender<T>;
pub(super) type SenderMpsc<T> = mpsc::Sender<T>;

/// A type alias for the receiver end of a multi-producer, single-consumer channel.
pub type ReceiverMpsc<T> = mpsc::Receiver<T>;
pub(super) type ReceiverMpsc<T> = mpsc::Receiver<T>;

/// A type alias for an atomic swap operation on a shared value.
pub type AtomicSwap<T> = Arc<ArcSwap<T>>;
pub(super) type AtomicSwap<T> = Arc<ArcSwap<T>>;

0 comments on commit 38a8b45

Please sign in to comment.