pub struct Ring<M: Ord + Clone> { /* private fields */ }Expand description
a ring of tokens; M names a member (an address, a backend)
Implementations§
Source§impl<M: Ord + Clone> Ring<M>
impl<M: Ord + Clone> Ring<M>
pub fn new() -> Ring<M>
Sourcepub fn add(&mut self, m: M, key: &str, vnodes: u32)
pub fn add(&mut self, m: M, key: &str, vnodes: u32)
adds a member with vnodes tokens made from key (a member that is there already gets
its tokens again)
pub fn is_empty(&self) -> bool
Sourcepub fn preference(&self, h: u64, n: usize) -> Vec<M>
pub fn preference(&self, h: u64, n: usize) -> Vec<M>
the first n distinct members from h on, in ring order
Sourcepub fn preference_by(&self, h: u64, n: usize, ok: impl Fn(&M) -> bool) -> Vec<M>
pub fn preference_by(&self, h: u64, n: usize, ok: impl Fn(&M) -> bool) -> Vec<M>
the first n distinct members from h on that ok accepts
the part of the hash space each member owns, in parts per million (sorted by member)
Trait Implementations§
impl<M: Eq + Ord + Clone> Eq for Ring<M>
impl<M: PartialEq + Ord + Clone> StructuralPartialEq for Ring<M>
Auto Trait Implementations§
impl<M> Forget for Ring<M>
impl<M> Freeze for Ring<M>
impl<M> RefUnwindSafe for Ring<M>
impl<M> Send for Ring<M>
impl<M> Sync for Ring<M>
impl<M> Unpin for Ring<M>
impl<M> UnsafeUnpin for Ring<M>
impl<M> UnwindSafe for Ring<M>
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