pub struct ConsistentHashing {
pub ring: BTreeMap<u64, String>,
pub nodes: HashSet<String>,
pub virtual_nodes_count: u32,
}
Fields§
§ring: BTreeMap<u64, String>
§nodes: HashSet<String>
§virtual_nodes_count: u32
Implementations§
Source§impl ConsistentHashing
impl ConsistentHashing
pub fn new(virtual_nodes_count: u32) -> Self
pub fn new_with_nodes(virtual_nodes_count: u32, nodes: Vec<String>) -> Self
pub fn get_virtual_node_form(&self, node: &str, i: u32) -> String
pub fn get_current_state(&self) -> Vec<(u64, String)>
pub fn hash<U: Hash>(&self, item: &U) -> u64
pub fn get_previous_node(&self, node: &str) -> Option<(&u64, &String)>
pub fn get_previous_node_by_hash(&self, hash: u64) -> Option<(&u64, &String)>
pub fn get_next_node(&self, node: &str) -> Option<(&u64, &String)>
pub fn get_next_node_by_hash(&self, hash: u64) -> Option<(&u64, &String)>
Sourcepub fn add_node(
&mut self,
node: &str,
) -> Result<Vec<Transaction<String, u64>>, ConsistentHashingError>
pub fn add_node( &mut self, node: &str, ) -> Result<Vec<Transaction<String, u64>>, ConsistentHashingError>
hashes nodex-i …
pub fn remove_node( &mut self, node: &str, ) -> Result<Vec<Transaction<String, u64>>, ConsistentHashingError>
pub fn set_virtual_nodes_count( &mut self, count: u32, ) -> Result<Vec<Transaction<String, u64>>, ConsistentHashingError>
pub fn get_node<U: Hash>(&self, key: &U) -> (Option<&String>, Option<u64>)
Auto Trait Implementations§
impl Freeze for ConsistentHashing
impl RefUnwindSafe for ConsistentHashing
impl Send for ConsistentHashing
impl Sync for ConsistentHashing
impl Unpin for ConsistentHashing
impl UnwindSafe for ConsistentHashing
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