pub struct HashRing { /* private fields */ }Expand description
A consistent hash ring for distributing keys across nodes.
Implementations§
Source§impl HashRing
impl HashRing
Sourcepub fn default_ring() -> Self
pub fn default_ring() -> Self
Create a hash ring with default settings (150 virtual nodes).
Sourcepub fn remove_node(&mut self, node_id: &NodeId)
pub fn remove_node(&mut self, node_id: &NodeId)
Remove a node from the ring.
Sourcepub fn get_nodes(&self, key: &str, count: usize) -> Vec<&NodeId>
pub fn get_nodes(&self, key: &str, count: usize) -> Vec<&NodeId>
Get N nodes for a key (for replication).
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Get the number of nodes.
Sourcepub fn virtual_node_count(&self) -> usize
pub fn virtual_node_count(&self) -> usize
Get the number of virtual nodes.
Sourcepub fn key_position(&self, key: &str) -> u64
pub fn key_position(&self, key: &str) -> u64
Get the hash position for a key.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for HashRing
impl RefUnwindSafe for HashRing
impl Send for HashRing
impl Sync for HashRing
impl Unpin for HashRing
impl UnsafeUnpin for HashRing
impl UnwindSafe for HashRing
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