diff --git a/redis/src/cluster_async/mod.rs b/redis/src/cluster_async/mod.rs index 5931b0cd5..068b34722 100644 --- a/redis/src/cluster_async/mod.rs +++ b/redis/src/cluster_async/mod.rs @@ -754,7 +754,7 @@ where num_of_nodes_to_query, inner.cluster_params.read_from_replicas, )?; - info!("Found slot map: {new_slots:?}"); + info!("Found slot map: {new_slots}"); let connections = &*read_guard; // Create a new connection vector of the found nodes let mut nodes = new_slots.values().flatten().collect::>(); diff --git a/redis/src/cluster_topology.rs b/redis/src/cluster_topology.rs index 5e1e768ec..fcb042496 100644 --- a/redis/src/cluster_topology.rs +++ b/redis/src/cluster_topology.rs @@ -5,6 +5,7 @@ use crate::cluster_routing::{MultipleNodeRoutingInfo, Route, Slot, SlotAddr, Slo use crate::{cluster::TlsMode, ErrorKind, RedisError, RedisResult, Value}; use derivative::Derivative; use std::collections::{hash_map::DefaultHasher, BTreeMap, HashMap, HashSet}; +use std::fmt::Display; use std::hash::{Hash, Hasher}; use std::sync::atomic::AtomicUsize; use std::time::Duration; @@ -167,6 +168,23 @@ impl SlotMap { } } +impl Display for SlotMap { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + writeln!(f, "Strategy: {:?}. Slot mapping:", self.read_from_replica)?; + for (end, slot_map_value) in self.slots.iter() { + writeln!( + f, + "({}-{}): primary: {}, replicas: {:?}", + slot_map_value.start, + end, + slot_map_value.addrs.primary, + slot_map_value.addrs.replicas + )?; + } + Ok(()) + } +} + pub(crate) fn slot(key: &[u8]) -> u16 { crc16::State::::calculate(key) % SLOT_SIZE }