From 262ef71e65536211bdd77c95bc6fb79817849622 Mon Sep 17 00:00:00 2001 From: Yury-Fridlyand Date: Tue, 3 Dec 2024 14:32:38 -0800 Subject: [PATCH 1/2] lint Signed-off-by: Yury-Fridlyand --- glide-core/redis-rs/redis/src/cluster.rs | 2 +- glide-core/redis-rs/redis/src/cluster_routing.rs | 2 +- glide-core/redis-rs/redis/src/cmd.rs | 2 +- glide-core/redis-rs/redis/src/connection.rs | 4 ++-- glide-core/redis-rs/redis/src/types.rs | 4 ++-- .../tests/test_async_cluster_connections_logic.rs | 8 ++++++++ .../redis-rs/redis/tests/test_cluster_async.rs | 12 ++++++------ 7 files changed, 21 insertions(+), 13 deletions(-) diff --git a/glide-core/redis-rs/redis/src/cluster.rs b/glide-core/redis-rs/redis/src/cluster.rs index ffd537152a..57d3a7eae4 100644 --- a/glide-core/redis-rs/redis/src/cluster.rs +++ b/glide-core/redis-rs/redis/src/cluster.rs @@ -105,7 +105,7 @@ impl<'a> Input<'a> { } } -impl<'a> Routable for Input<'a> { +impl Routable for Input<'_> { fn arg_idx(&self, idx: usize) -> Option<&[u8]> { match self { Input::Slice { cmd: _, routable } => routable.arg_idx(idx), diff --git a/glide-core/redis-rs/redis/src/cluster_routing.rs b/glide-core/redis-rs/redis/src/cluster_routing.rs index eab3bf398a..8bf11d19d4 100644 --- a/glide-core/redis-rs/redis/src/cluster_routing.rs +++ b/glide-core/redis-rs/redis/src/cluster_routing.rs @@ -1378,7 +1378,7 @@ impl ShardAddrs { } } -impl<'a> IntoIterator for &'a ShardAddrs { +impl IntoIterator for &ShardAddrs { type Item = Arc; type IntoIter = std::iter::Chain>, std::vec::IntoIter>>; diff --git a/glide-core/redis-rs/redis/src/cmd.rs b/glide-core/redis-rs/redis/src/cmd.rs index 3e248dad6f..92e8aea989 100644 --- a/glide-core/redis-rs/redis/src/cmd.rs +++ b/glide-core/redis-rs/redis/src/cmd.rs @@ -40,7 +40,7 @@ pub struct Iter<'a, T: FromRedisValue> { cmd: Cmd, } -impl<'a, T: FromRedisValue> Iterator for Iter<'a, T> { +impl Iterator for Iter<'_, T> { type Item = T; #[inline] diff --git a/glide-core/redis-rs/redis/src/connection.rs b/glide-core/redis-rs/redis/src/connection.rs index f75b9df494..527fb40fa0 100644 --- a/glide-core/redis-rs/redis/src/connection.rs +++ b/glide-core/redis-rs/redis/src/connection.rs @@ -287,7 +287,7 @@ impl IntoConnectionInfo for ConnectionInfo { /// - Specifying DB: `redis://127.0.0.1:6379/0` /// - Enabling TLS: `rediss://127.0.0.1:6379` /// - Enabling Insecure TLS: `rediss://127.0.0.1:6379/#insecure` -impl<'a> IntoConnectionInfo for &'a str { +impl IntoConnectionInfo for &str { fn into_connection_info(self) -> RedisResult { match parse_redis_url(self) { Some(u) => u.into_connection_info(), @@ -1578,7 +1578,7 @@ impl<'a> PubSub<'a> { } } -impl<'a> Drop for PubSub<'a> { +impl Drop for PubSub<'_> { fn drop(&mut self) { let _ = self.con.exit_pubsub(); } diff --git a/glide-core/redis-rs/redis/src/types.rs b/glide-core/redis-rs/redis/src/types.rs index 2d8035d697..f66be0291e 100644 --- a/glide-core/redis-rs/redis/src/types.rs +++ b/glide-core/redis-rs/redis/src/types.rs @@ -1443,7 +1443,7 @@ impl ToRedisArgs for String { } } -impl<'a> ToRedisArgs for &'a str { +impl ToRedisArgs for &str { fn write_redis_args(&self, out: &mut W) where W: ?Sized + RedisWrite, @@ -1465,7 +1465,7 @@ impl ToRedisArgs for Vec { } } -impl<'a, T: ToRedisArgs> ToRedisArgs for &'a [T] { +impl ToRedisArgs for &[T] { fn write_redis_args(&self, out: &mut W) where W: ?Sized + RedisWrite, diff --git a/glide-core/redis-rs/redis/tests/test_async_cluster_connections_logic.rs b/glide-core/redis-rs/redis/tests/test_async_cluster_connections_logic.rs index 356c5bfc8c..1b4acb3a20 100644 --- a/glide-core/redis-rs/redis/tests/test_async_cluster_connections_logic.rs +++ b/glide-core/redis-rs/redis/tests/test_async_cluster_connections_logic.rs @@ -236,6 +236,7 @@ mod test_connect_and_check { ConnectionDetails { conn: user_conn, ip: Some(ip), + az: None, } .into_future(), None, @@ -283,6 +284,7 @@ mod test_connect_and_check { ConnectionDetails { conn: user_conn, ip: prev_ip, + az: None, } .into_future(), None, @@ -339,12 +341,14 @@ mod test_connect_and_check { ConnectionDetails { conn: old_user_conn, ip: Some(prev_ip), + az: None, } .into_future(), Some( ConnectionDetails { conn: management_conn, ip: Some(prev_ip), + az: None, } .into_future(), ), @@ -380,12 +384,14 @@ mod test_check_node_connections { ConnectionDetails { conn: get_mock_connection_with_port(name, 1, 6380), ip, + az: None, } .into_future(), Some( ConnectionDetails { conn: get_mock_connection_with_port(name, 2, 6381), ip, + az: None, } .into_future(), ), @@ -463,6 +469,7 @@ mod test_check_node_connections { ConnectionDetails { conn: get_mock_connection(name, 1), ip, + az: None, } .into_future(), None, @@ -547,6 +554,7 @@ mod test_check_node_connections { ConnectionDetails { conn: get_mock_connection(name, 1), ip: None, + az: None, } .into_future(), None, diff --git a/glide-core/redis-rs/redis/tests/test_cluster_async.rs b/glide-core/redis-rs/redis/tests/test_cluster_async.rs index 7273f98702..c69a9f933f 100644 --- a/glide-core/redis-rs/redis/tests/test_cluster_async.rs +++ b/glide-core/redis-rs/redis/tests/test_cluster_async.rs @@ -23,7 +23,7 @@ async fn engine_version_less_than(min_version: &str) -> bool { ); return true; } - return false; + false } /// Static function to get the engine version. When version looks like 8.0.0 -> 80000 and 12.0.1 -> 120001. @@ -49,10 +49,10 @@ async fn get_cluster_version() -> usize { cluster_version.set( parse_version_from_info(info_result.clone()) - .expect(format!("Invalid version string in INFO : {info_result}").as_str()), + .unwrap_or_else(|| panic!("Invalid version string in INFO : {info_result}")), ); } - return cluster_version.get(); + cluster_version.get() } fn parse_version_from_info(info: String) -> Option { @@ -273,7 +273,7 @@ mod cluster_async { .unwrap(); let info_result = redis::from_owned_redis_value::>(info).unwrap(); - let get_cmdstat = format!("cmdstat_get:calls="); + let get_cmdstat = "cmdstat_get:calls=".to_string(); let n_get_cmdstat = format!("cmdstat_get:calls={}", n); let client_az = format!("availability_zone:{}", az); @@ -363,7 +363,7 @@ mod cluster_async { .unwrap(); let info_result = redis::from_owned_redis_value::>(info).unwrap(); - let get_cmdstat = format!("cmdstat_get:calls="); + let get_cmdstat = "cmdstat_get:calls=".to_string(); let n_get_cmdstat = format!("cmdstat_get:calls={}", n); let client_az = format!("availability_zone:{}", az); @@ -385,7 +385,7 @@ mod cluster_async { (matching_entries_count.try_into() as Result).unwrap(), replica_num, "Test failed: expected exactly '{}' entries with '{}' and '{}', found {}", - replica_num.to_string(), + replica_num, get_cmdstat, client_az, matching_entries_count From b4cda074ca17f0b3c0d08f5bed5407cc7a41a261 Mon Sep 17 00:00:00 2001 From: Yury-Fridlyand Date: Tue, 3 Dec 2024 14:44:57 -0800 Subject: [PATCH 2/2] fix docs Signed-off-by: Yury-Fridlyand --- .../redis/src/commands/cluster_scan.rs | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/glide-core/redis-rs/redis/src/commands/cluster_scan.rs b/glide-core/redis-rs/redis/src/commands/cluster_scan.rs index 0fccb0e6f5..109aceca22 100644 --- a/glide-core/redis-rs/redis/src/commands/cluster_scan.rs +++ b/glide-core/redis-rs/redis/src/commands/cluster_scan.rs @@ -1,3 +1,18 @@ +//! This module contains the implementation of scanning operations in a Redis cluster. +//! +//! The [`ClusterScanArgs`] struct represents the arguments for a cluster scan operation, +//! including the scan state reference, match pattern, count, and object type. +//! +//! The [[`ScanStateRC`]] struct is a wrapper for managing the state of a scan operation in a cluster. +//! It holds a reference to the scan state and provides methods for accessing the state. +//! +//! The [[`ClusterInScan`]] trait defines the methods for interacting with a Redis cluster during scanning, +//! including retrieving address information, refreshing slot mapping, and routing commands to specific address. +//! +//! The [[`ScanState`]] struct represents the state of a scan operation in a Redis cluster. +//! It holds information about the current scan state, including the cursor position, scanned slots map, +//! address being scanned, and address's epoch. + use crate::aio::ConnectionLike; use crate::cluster_async::{ ClusterConnInner, Connect, Core, InternalRoutingInfo, InternalSingleNodeRouting, RefreshPolicy, @@ -10,21 +25,6 @@ use async_trait::async_trait; use std::sync::Arc; use strum_macros::Display; -/// This module contains the implementation of scanning operations in a Redis cluster. -/// -/// The [`ClusterScanArgs`] struct represents the arguments for a cluster scan operation, -/// including the scan state reference, match pattern, count, and object type. -/// -/// The [[`ScanStateRC`]] struct is a wrapper for managing the state of a scan operation in a cluster. -/// It holds a reference to the scan state and provides methods for accessing the state. -/// -/// The [[`ClusterInScan`]] trait defines the methods for interacting with a Redis cluster during scanning, -/// including retrieving address information, refreshing slot mapping, and routing commands to specific address. -/// -/// The [[`ScanState`]] struct represents the state of a scan operation in a Redis cluster. -/// It holds information about the current scan state, including the cursor position, scanned slots map, -/// address being scanned, and address's epoch. - const BITS_PER_U64: usize = u64::BITS as usize; const NUM_OF_SLOTS: usize = SLOT_SIZE as usize; const BITS_ARRAY_SIZE: usize = NUM_OF_SLOTS / BITS_PER_U64;