Skip to content

Commit

Permalink
Merge pull request #110 from nihohit/reduce-visibility
Browse files Browse the repository at this point in the history
Reduce visibility of types that are used only for testing.
  • Loading branch information
shachlanAmazon authored Jan 29, 2024
2 parents 47391a4 + deaa4ea commit 0272c88
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 15 deletions.
9 changes: 7 additions & 2 deletions redis/src/cluster_async/connections_logic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::{
net::{IpAddr, SocketAddr},
};

use super::{AsyncClusterNode, Connect};
use super::{connections_container::ClusterNode, Connect};
use crate::{
aio::{get_socket_addrs, ConnectionLike},
cluster::get_connection_info,
Expand All @@ -12,9 +12,14 @@ use crate::{
};

use futures_time::future::FutureExt;
use futures_util::join;
use futures_util::{future::BoxFuture, join};
use tracing::warn;

pub(crate) type ConnectionFuture<C> = futures::future::Shared<BoxFuture<'static, C>>;
/// Cluster node for async connections
#[doc(hidden)]
pub type AsyncClusterNode<C> = ClusterNode<ConnectionFuture<C>>;

#[doc(hidden)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum RefreshConnectionType {
Expand Down
12 changes: 6 additions & 6 deletions redis/src/cluster_async/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@
//! ```
mod connections_container;
#[doc(hidden)]
pub mod connections_logic;
mod connections_logic;
/// Exposed only for testing.
pub mod testing {
pub use super::connections_logic::*;
}
use std::{
collections::HashMap,
fmt, io,
Expand All @@ -45,7 +48,7 @@ use crate::{
cluster::slot_cmd,
cluster_async::{
connections_container::ClusterNode,
connections_logic::{get_host_and_port_from_addr, get_or_create_conn},
connections_logic::{get_host_and_port_from_addr, get_or_create_conn, ConnectionFuture},
},
cluster_client::{ClusterParams, RetryParams},
cluster_routing::{
Expand Down Expand Up @@ -199,9 +202,6 @@ where
}
}

type ConnectionFuture<C> = future::Shared<BoxFuture<'static, C>>;
/// Cluster node for async connections
pub type AsyncClusterNode<C> = ClusterNode<ConnectionFuture<C>>;
type ConnectionMap<C> = connections_container::ConnectionsMap<ConnectionFuture<C>>;
type ConnectionsContainer<C> =
self::connections_container::ConnectionsContainer<ConnectionFuture<C>>;
Expand Down
8 changes: 5 additions & 3 deletions redis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -449,9 +449,11 @@ mod cluster_slotmap;
#[cfg(feature = "cluster")]
mod cluster_client;

// for testing purposes
#[cfg(feature = "cluster")]
pub use crate::cluster_client::ClusterParams;
/// for testing purposes
pub mod testing {
#[cfg(feature = "cluster")]
pub use crate::cluster_client::ClusterParams;
}

#[cfg(feature = "cluster")]
mod cluster_pipeline;
Expand Down
9 changes: 5 additions & 4 deletions redis/tests/test_async_cluster_connections_logic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ mod support;

use futures_util::FutureExt;
use redis::{
cluster_async::{connections_logic::RefreshConnectionType, AsyncClusterNode},
ClusterParams, ErrorKind,
cluster_async::testing::{AsyncClusterNode, RefreshConnectionType},
testing::ClusterParams,
ErrorKind,
};
use std::net::{IpAddr, Ipv4Addr};
use std::sync::Arc;
Expand All @@ -15,7 +16,7 @@ use support::{

mod test_connect_and_check {
use super::*;
use redis::cluster_async::connections_logic::connect_and_check;
use redis::cluster_async::testing::connect_and_check;

#[tokio::test]
async fn test_connect_and_check_connect_successfully() {
Expand Down Expand Up @@ -50,7 +51,7 @@ mod test_connect_and_check {
mod test_check_node_connections {

use super::*;
use redis::cluster_async::connections_logic::check_node_connections;
use redis::cluster_async::testing::check_node_connections;

#[tokio::test]
async fn test_check_node_connections_find_no_problem() {
Expand Down

0 comments on commit 0272c88

Please sign in to comment.