Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply linters to submodule #2783

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion glide-core/redis-rs/redis/src/cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion glide-core/redis-rs/redis/src/cluster_routing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1378,7 +1378,7 @@ impl ShardAddrs {
}
}

impl<'a> IntoIterator for &'a ShardAddrs {
impl IntoIterator for &ShardAddrs {
type Item = Arc<String>;
type IntoIter = std::iter::Chain<Once<Arc<String>>, std::vec::IntoIter<Arc<String>>>;

Expand Down
2 changes: 1 addition & 1 deletion glide-core/redis-rs/redis/src/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub struct Iter<'a, T: FromRedisValue> {
cmd: Cmd,
}

impl<'a, T: FromRedisValue> Iterator for Iter<'a, T> {
impl<T: FromRedisValue> Iterator for Iter<'_, T> {
type Item = T;

#[inline]
Expand Down
30 changes: 15 additions & 15 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,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;
Expand Down
4 changes: 2 additions & 2 deletions glide-core/redis-rs/redis/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ConnectionInfo> {
match parse_redis_url(self) {
Some(u) => u.into_connection_info(),
Expand Down Expand Up @@ -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();
}
Expand Down
4 changes: 2 additions & 2 deletions glide-core/redis-rs/redis/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1443,7 +1443,7 @@ impl ToRedisArgs for String {
}
}

impl<'a> ToRedisArgs for &'a str {
impl ToRedisArgs for &str {
fn write_redis_args<W>(&self, out: &mut W)
where
W: ?Sized + RedisWrite,
Expand All @@ -1465,7 +1465,7 @@ impl<T: ToRedisArgs> ToRedisArgs for Vec<T> {
}
}

impl<'a, T: ToRedisArgs> ToRedisArgs for &'a [T] {
impl<T: ToRedisArgs> ToRedisArgs for &[T] {
fn write_redis_args<W>(&self, out: &mut W)
where
W: ?Sized + RedisWrite,
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
Loading