pub struct Node {
pub key: CKey,
/* private fields */
}Expand description
Node is an element of a ring.
In a typical setup, a host has several nodes which act as “virtual” entry points. Each node is responsible for keys which are lower, or equal, to its key value, and points to its “next” node.
Fields§
§key: CKeyImplementations§
source§impl Node
impl Node
sourcepub fn new_rand() -> Node
pub fn new_rand() -> Node
Examples found in repository?
src/cluster.rs (line 36)
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
pub fn resize(&mut self, size: usize) {
while self.nodes.len() > size {
let to_remove = self.nodes.iter().next().unwrap().0.clone();
self.nodes.remove(&to_remove);
}
while self.nodes.len() < size {
let node = Node::new_rand();
match self.nodes.insert(node.key, node) {
// Really, there should be no dupes here, we're talking
// about *hopefully* random generation of 256 bit keys.
// Having dupes is unlikely, should it happen, let's call it.
Some(_) => panic!("duplicate node key"),
None => {}
}
}
}