Skip to content

Commit

Permalink
Apply linters to submodule (valkey-io#2783)
Browse files Browse the repository at this point in the history
* lint

Signed-off-by: Yury-Fridlyand <[email protected]>
  • Loading branch information
Yury-Fridlyand committed Dec 10, 2024
1 parent 81df696 commit 5ec307f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 20 deletions.
29 changes: 15 additions & 14 deletions glide-core/redis-rs/redis/src/commands/cluster_scan.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -10,20 +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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ mod test_connect_and_check {
ConnectionDetails {
conn: user_conn,
ip: Some(ip),
az: None,
}
.into_future(),
None,
Expand Down Expand Up @@ -283,6 +284,7 @@ mod test_connect_and_check {
ConnectionDetails {
conn: user_conn,
ip: prev_ip,
az: None,
}
.into_future(),
None,
Expand Down Expand Up @@ -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(),
),
Expand Down Expand Up @@ -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(),
),
Expand Down Expand Up @@ -463,6 +469,7 @@ mod test_check_node_connections {
ConnectionDetails {
conn: get_mock_connection(name, 1),
ip,
az: None,
}
.into_future(),
None,
Expand Down Expand Up @@ -547,6 +554,7 @@ mod test_check_node_connections {
ConnectionDetails {
conn: get_mock_connection(name, 1),
ip: None,
az: None,
}
.into_future(),
None,
Expand Down
12 changes: 6 additions & 6 deletions glide-core/redis-rs/redis/tests/test_cluster_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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<usize> {
Expand Down Expand Up @@ -273,7 +273,7 @@ mod cluster_async {
.unwrap();

let info_result = redis::from_owned_redis_value::<HashMap<String, String>>(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);

Expand Down Expand Up @@ -363,7 +363,7 @@ mod cluster_async {
.unwrap();

let info_result = redis::from_owned_redis_value::<HashMap<String, String>>(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);

Expand All @@ -385,7 +385,7 @@ mod cluster_async {
(matching_entries_count.try_into() as Result<u16, _>).unwrap(),
replica_num,
"Test failed: expected exactly '{}' entries with '{}' and '{}', found {}",
replica_num.to_string(),
replica_num,
get_cmdstat,
client_az,
matching_entries_count
Expand Down

0 comments on commit 5ec307f

Please sign in to comment.