pub struct ClusterTopology { /* private fields */ }Expand description
Manages cluster topology and slot mappings
Implementations§
Source§impl ClusterTopology
impl ClusterTopology
Sourcepub async fn get_node_for_slot(&self, slot: u16) -> Option<(String, u16)>
pub async fn get_node_for_slot(&self, slot: u16) -> Option<(String, u16)>
Get the node address for a given slot
Sourcepub async fn get_node_for_key(&self, key: &[u8]) -> Option<(String, u16)>
pub async fn get_node_for_key(&self, key: &[u8]) -> Option<(String, u16)>
Get the node address for a given key
Sourcepub async fn update_slot_mapping(&self, slot: u16, host: String, port: u16)
pub async fn update_slot_mapping(&self, slot: u16, host: String, port: u16)
Update the slot mapping when a MOVED redirect occurs
Sourcepub async fn clear_slots(&self)
pub async fn clear_slots(&self)
Clear all slot mappings (useful for full topology refresh)
Sourcepub async fn update_from_cluster_slots(
&self,
slots_data: Vec<Vec<(i64, String, i64)>>,
) -> RedisResult<()>
pub async fn update_from_cluster_slots( &self, slots_data: Vec<Vec<(i64, String, i64)>>, ) -> RedisResult<()>
Update the topology from CLUSTER SLOTS response
The response is an array of slot ranges, where each range is: [start_slot, end_slot, [master_host, master_port], [replica_host, replica_port], …]
Sourcepub async fn get_all_nodes(&self) -> Vec<NodeInfo>
pub async fn get_all_nodes(&self) -> Vec<NodeInfo>
Get all known nodes
Sourcepub async fn mapped_slots_count(&self) -> usize
pub async fn mapped_slots_count(&self) -> usize
Get the number of slots currently mapped
Trait Implementations§
Source§impl Clone for ClusterTopology
impl Clone for ClusterTopology
Source§fn clone(&self) -> ClusterTopology
fn clone(&self) -> ClusterTopology
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ClusterTopology
impl !RefUnwindSafe for ClusterTopology
impl Send for ClusterTopology
impl Sync for ClusterTopology
impl Unpin for ClusterTopology
impl !UnwindSafe for ClusterTopology
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more