Skip to content

Commit

Permalink
Rename reset_connection_password to replace_connection_password for c…
Browse files Browse the repository at this point in the history
…onsistency and remove unused derivative dependency

fixed some minor issues

Signed-off-by: avifenesh <[email protected]>
  • Loading branch information
avifenesh committed Nov 10, 2024
1 parent 2367b6a commit 49111ca
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 52 deletions.
5 changes: 2 additions & 3 deletions glide-core/redis-rs/redis/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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 }
Expand Down Expand Up @@ -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 = [
Expand Down
75 changes: 39 additions & 36 deletions glide-core/redis-rs/redis/src/cluster_async/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
}

Expand Down Expand Up @@ -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");
}

Expand Down
5 changes: 0 additions & 5 deletions glide-core/redis-rs/redis/src/cluster_topology.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Slot>),
}

Expand Down
2 changes: 1 addition & 1 deletion glide-core/src/protobuf/command_request.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
8 changes: 4 additions & 4 deletions glide-core/src/socket_listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -522,12 +522,12 @@ fn handle_request(request: CommandRequest, mut client: Client, writer: Rc<Writer
Err(e) => 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()),
Expand Down
2 changes: 1 addition & 1 deletion node/src/BaseClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions python/python/glide/glide_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 49111ca

Please sign in to comment.