pub struct ConsistentHashRing { /* private fields */ }Expand description
A consistent hash ring with virtual-node support for even key distribution.
Uses the FNV-1a hash algorithm for deterministic, dependency-free hashing.
Implementations§
Source§impl ConsistentHashRing
impl ConsistentHashRing
Sourcepub fn new(virtual_nodes: u32) -> Self
pub fn new(virtual_nodes: u32) -> Self
Create a new ring with the given number of virtual nodes per physical node.
Sourcepub fn remove_node(&mut self, id: u64)
pub fn remove_node(&mut self, id: u64)
Remove a physical node from the ring.
Sourcepub fn get_node(&self, key: &[u8]) -> Option<u64>
pub fn get_node(&self, key: &[u8]) -> Option<u64>
Look up which physical node owns the given key.
Returns None if the ring is empty.
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Number of registered physical nodes.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ConsistentHashRing
impl RefUnwindSafe for ConsistentHashRing
impl Send for ConsistentHashRing
impl Sync for ConsistentHashRing
impl Unpin for ConsistentHashRing
impl UnsafeUnpin for ConsistentHashRing
impl UnwindSafe for ConsistentHashRing
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request