pub struct ShardMap { /* private fields */ }Expand description
Consistent hash ring for shard mapping.
Implementations§
Source§impl ShardMap
impl ShardMap
Sourcepub fn with_config(config: ShardMapConfig) -> Self
pub fn with_config(config: ShardMapConfig) -> Self
Create a shard map with custom configuration.
Sourcepub fn remove_node(&mut self, node_id: &str) -> bool
pub fn remove_node(&mut self, node_id: &str) -> bool
Remove a node from the ring.
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Get the number of physical nodes.
Sourcepub fn vnode_count(&self) -> usize
pub fn vnode_count(&self) -> usize
Get the total number of virtual nodes on the ring.
Sourcepub fn load_distribution(&self) -> HashMap<String, usize>
pub fn load_distribution(&self) -> HashMap<String, usize>
Compute load distribution: how many virtual nodes each physical node owns.
Sourcepub fn load_factor(&self) -> f64
pub fn load_factor(&self) -> f64
Compute the load factor (std dev / mean of vnode counts).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ShardMap
impl RefUnwindSafe for ShardMap
impl Send for ShardMap
impl Sync for ShardMap
impl Unpin for ShardMap
impl UnsafeUnpin for ShardMap
impl UnwindSafe for ShardMap
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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