From 49111ca01a50e48325f0343923f80ffde524ddf4 Mon Sep 17 00:00:00 2001 From: avifenesh Date: Sun, 10 Nov 2024 19:41:23 +0000 Subject: [PATCH] Rename reset_connection_password to replace_connection_password for consistency and remove unused derivative dependency fixed some minor issues Signed-off-by: avifenesh --- glide-core/redis-rs/redis/Cargo.toml | 5 +- .../redis-rs/redis/src/cluster_async/mod.rs | 75 ++++++++++--------- .../redis-rs/redis/src/cluster_topology.rs | 5 -- glide-core/src/protobuf/command_request.proto | 2 +- glide-core/src/socket_listener.rs | 8 +- node/src/BaseClient.ts | 2 +- python/python/glide/glide_client.py | 4 +- 7 files changed, 49 insertions(+), 52 deletions(-) diff --git a/glide-core/redis-rs/redis/Cargo.toml b/glide-core/redis-rs/redis/Cargo.toml index 6311869e10..51b8e74d51 100644 --- a/glide-core/redis-rs/redis/Cargo.toml +++ b/glide-core/redis-rs/redis/Cargo.toml @@ -8,7 +8,7 @@ repository = "https://github.com/redis-rs/redis-rs" documentation = "https://docs.rs/redis" license = "BSD-3-Clause" edition = "2021" -rust-version = "1.65" +rust-version = "1.80" readme = "../README.md" [package.metadata.docs.rs] @@ -61,7 +61,6 @@ r2d2 = { version = "0.8.8", optional = true } # Only needed for cluster crc16 = { version = "0.4", optional = true } rand = { version = "0.8", optional = true } -derivative = { version = "2.2.0", optional = true } # Only needed for async cluster dashmap = { version = "6.0", optional = true } @@ -134,7 +133,7 @@ aio = [ ] geospatial = [] json = ["serde", "serde/derive", "serde_json"] -cluster = ["crc16", "rand", "derivative"] +cluster = ["crc16", "rand"] script = ["sha1_smol"] tls-native-tls = ["native-tls"] tls-rustls = [ diff --git a/glide-core/redis-rs/redis/src/cluster_async/mod.rs b/glide-core/redis-rs/redis/src/cluster_async/mod.rs index c811958a6d..d517a233a3 100644 --- a/glide-core/redis-rs/redis/src/cluster_async/mod.rs +++ b/glide-core/redis-rs/redis/src/cluster_async/mod.rs @@ -469,7 +469,7 @@ where { self.cluster_params .read() - .map(|guard| f(&*guard).clone()) + .map(|guard| f(&guard).clone()) .map_err(|_| RedisError::from((ErrorKind::ClientError, MUTEX_READ_ERR))) } @@ -1400,43 +1400,46 @@ where let subscriptions_by_address = &inner.subscriptions_by_address; let glide_connection_options = &inner.glide_connection_options; - let _ = stream::iter(addresses.into_iter()).fold( - &*connections_container, - |connections_container, address| async move { - let node_option = if check_existing_conn { - connections_container.remove_node(&address) - } else { - None - }; + stream::iter(addresses.into_iter()) + .fold( + &*connections_container, + |connections_container, address| async move { + let node_option = if check_existing_conn { + connections_container.remove_node(&address) + } else { + None + }; - // override subscriptions for this connection - let subs_guard = subscriptions_by_address.read().await; - let mut cluster_params_cloned = - cluster_params.read().expect(MUTEX_READ_ERR).clone(); - cluster_params_cloned.pubsub_subscriptions = subs_guard.get(&address).cloned(); - drop(subs_guard); - let node = get_or_create_conn( - &address, - node_option, - &cluster_params_cloned, - conn_type, - glide_connection_options.clone(), - ) - .await; - match node { - Ok(node) => { - connections_container.replace_or_add_connection_for_address(address, node); - } - Err(err) => { - warn!( - "Failed to refresh connection for node {}. Error: `{:?}`", - address, err - ); + // override subscriptions for this connection + let subs_guard = subscriptions_by_address.read().await; + let mut cluster_params_cloned = + cluster_params.read().expect(MUTEX_READ_ERR).clone(); + cluster_params_cloned.pubsub_subscriptions = subs_guard.get(&address).cloned(); + drop(subs_guard); + let node = get_or_create_conn( + &address, + node_option, + &cluster_params_cloned, + conn_type, + glide_connection_options.clone(), + ) + .await; + match node { + Ok(node) => { + connections_container + .replace_or_add_connection_for_address(address, node); + } + Err(err) => { + warn!( + "Failed to refresh connection for node {}. Error: `{:?}`", + address, err + ); + } } - } - connections_container - }, - ); + connections_container + }, + ) + .await; info!("refresh connections completed"); } diff --git a/glide-core/redis-rs/redis/src/cluster_topology.rs b/glide-core/redis-rs/redis/src/cluster_topology.rs index a2ce9ea078..1fef2dbd61 100644 --- a/glide-core/redis-rs/redis/src/cluster_topology.rs +++ b/glide-core/redis-rs/redis/src/cluster_topology.rs @@ -8,7 +8,6 @@ use crate::cluster_slotmap::{ReadFromReplicaStrategy, SlotMap}; use crate::{cluster::TlsMode, ErrorKind, RedisError, RedisResult, Value}; #[cfg(all(feature = "cluster-async", not(feature = "tokio-comp")))] use async_std::sync::RwLock; -use derivative::Derivative; use std::collections::{hash_map::DefaultHasher, HashMap}; use std::hash::{Hash, Hasher}; use std::sync::atomic::AtomicBool; @@ -58,14 +57,10 @@ impl SlotRefreshState { } } -#[derive(Derivative)] -#[derivative(PartialEq, Eq)] #[derive(Debug)] pub(crate) struct TopologyView { pub(crate) hash_value: TopologyHash, - #[derivative(PartialEq = "ignore")] pub(crate) nodes_count: u16, - #[derivative(PartialEq = "ignore")] slots_and_count: (u16, Vec), } diff --git a/glide-core/src/protobuf/command_request.proto b/glide-core/src/protobuf/command_request.proto index 5e0bec3df3..ada6437475 100644 --- a/glide-core/src/protobuf/command_request.proto +++ b/glide-core/src/protobuf/command_request.proto @@ -522,7 +522,7 @@ message CommandRequest { ScriptInvocation script_invocation = 4; ScriptInvocationPointers script_invocation_pointers = 5; ClusterScan cluster_scan = 6; - ReplaceConnectionPassword reset_connection_password = 7; + ReplaceConnectionPassword replace_connection_password = 7; } Routes route = 8; } diff --git a/glide-core/src/socket_listener.rs b/glide-core/src/socket_listener.rs index aa6284e591..3e0bc7c6b4 100644 --- a/glide-core/src/socket_listener.rs +++ b/glide-core/src/socket_listener.rs @@ -522,12 +522,12 @@ fn handle_request(request: CommandRequest, mut client: Client, writer: Rc Err(e), } } - command_request::Command::ResetConnectionPassword( - reset_connection_password_command, + command_request::Command::ReplaceConnectionPassword( + replace_connection_password_command, ) => client .replace_connection_password( - reset_connection_password_command.password.to_string(), - reset_connection_password_command.re_auth, + replace_connection_password_command.password.to_string(), + replace_connection_password_command.re_auth, ) .await .map_err(|err| err.into()), diff --git a/node/src/BaseClient.ts b/node/src/BaseClient.ts index 5fdd6e8f35..5f1c7175fa 100644 --- a/node/src/BaseClient.ts +++ b/node/src/BaseClient.ts @@ -1010,7 +1010,7 @@ export class BaseClient { : command instanceof command_request.ReplaceConnectionPassword ? command_request.CommandRequest.create({ callbackIdx, - resetConnectionPassword: command, + replaceConnectionPassword: command, }) : command_request.CommandRequest.create({ callbackIdx, diff --git a/python/python/glide/glide_client.py b/python/python/glide/glide_client.py index 31bae00a67..666a998987 100644 --- a/python/python/glide/glide_client.py +++ b/python/python/glide/glide_client.py @@ -537,8 +537,8 @@ async def _replace_connection_password( ) -> TResult: request = CommandRequest() request.callback_idx = self._get_callback_index() - request.reset_connection_password.password = password - request.reset_connection_password.re_auth = re_auth + request.replace_connection_password.password = password + request.replace_connection_password.re_auth = re_auth response = await self._write_request_await_response(request) # Update the client binding side password if managed to change core configuration password if response is OK: