pub struct ConsistentHashRing { /* private fields */ }Expand description
Consistent hash ring for PID-to-node assignment.
Uses virtual nodes for even distribution across cluster members.
When the cluster feature is enabled, this delegates to
ruvector_cluster::ConsistentHashRing under the hood; otherwise
a standalone implementation is provided so the mesh module can
still compile without the full cluster dependency.
Implementations§
Source§impl ConsistentHashRing
impl ConsistentHashRing
Sourcepub fn new(virtual_nodes: usize) -> Self
pub fn new(virtual_nodes: usize) -> Self
Create a new hash ring with the given number of virtual nodes per real node. Higher values give more even distribution.
Sourcepub fn remove_node(&mut self, node_id: &str)
pub fn remove_node(&mut self, node_id: &str)
Remove a node from the ring.
Sourcepub fn assign(&self, pid: u64) -> Option<&str>
pub fn assign(&self, pid: u64) -> Option<&str>
Find which node owns a given PID (clockwise walk).
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Number of distinct real nodes in the ring.
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more