pub struct NodeRegistry { /* private fields */ }Expand description
Node Registry manages cluster topology
Implementations§
Source§impl NodeRegistry
impl NodeRegistry
Sourcepub fn new(partition_count: u32) -> Self
pub fn new(partition_count: u32) -> Self
Create new node registry
§Arguments
partition_count: Total fixed partitions (32 for single-node, 1024+ for cluster)
Sourcepub fn register_node(&self, node: Node)
pub fn register_node(&self, node: Node)
Register a node in the cluster
Automatically rebalances partitions across healthy nodes.
Sourcepub fn unregister_node(&self, node_id: u32)
pub fn unregister_node(&self, node_id: u32)
Unregister a node from the cluster
Triggers automatic rebalancing to remaining nodes.
Sourcepub fn set_node_health(&self, node_id: u32, healthy: bool)
pub fn set_node_health(&self, node_id: u32, healthy: bool)
Mark node as healthy or unhealthy
Unhealthy nodes are excluded from partition assignment.
Sourcepub fn node_for_partition(&self, partition_id: u32) -> Option<u32>
pub fn node_for_partition(&self, partition_id: u32) -> Option<u32>
Find node responsible for a partition
Returns None if no healthy node is assigned to the partition.
Sourcepub fn healthy_nodes(&self) -> Vec<Node>
pub fn healthy_nodes(&self) -> Vec<Node>
Get healthy nodes
Sourcepub fn partition_distribution(&self) -> HashMap<u32, Vec<u32>>
pub fn partition_distribution(&self) -> HashMap<u32, Vec<u32>>
Get partition distribution statistics
Sourcepub fn is_cluster_healthy(&self) -> bool
pub fn is_cluster_healthy(&self) -> bool
Check if cluster is healthy
Returns true if all partitions have at least one healthy node assigned.
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Get node count
Sourcepub fn healthy_node_count(&self) -> usize
pub fn healthy_node_count(&self) -> usize
Get healthy node count
Auto Trait Implementations§
impl Freeze for NodeRegistry
impl !RefUnwindSafe for NodeRegistry
impl Send for NodeRegistry
impl Sync for NodeRegistry
impl Unpin for NodeRegistry
impl !UnwindSafe for NodeRegistry
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§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