pub struct ClusterMembership { /* private fields */ }Implementations§
Source§impl ClusterMembership
impl ClusterMembership
Sourcepub fn new(config: ClusterConfig) -> Self
pub fn new(config: ClusterConfig) -> Self
Create a new cluster membership tracker.
Sourcepub fn with_min_peer_interval(self, interval: Duration) -> Self
pub fn with_min_peer_interval(self, interval: Duration) -> Self
Set the minimum interval between peer additions (builder style).
Sourcepub fn config(&self) -> &ClusterConfig
pub fn config(&self) -> &ClusterConfig
Get the cluster configuration.
Sourcepub fn local_node_id(&self) -> &str
pub fn local_node_id(&self) -> &str
Get this node’s ID.
Sourcepub fn add_peer(&self, peer: PeerNode) -> Result<(), ClusterError>
pub fn add_peer(&self, peer: PeerNode) -> Result<(), ClusterError>
Register a peer node.
Rate-limited to at most one addition per min_peer_add_interval
(default 100 ms) to prevent join-flood attacks.
Sourcepub fn remove_peer(&self, node_id: &str) -> Result<PeerNode, ClusterError>
pub fn remove_peer(&self, node_id: &str) -> Result<PeerNode, ClusterError>
Remove a peer node.
Sourcepub fn update_state(
&self,
node_id: &str,
new_state: NodeState,
) -> Result<(), ClusterError>
pub fn update_state( &self, node_id: &str, new_state: NodeState, ) -> Result<(), ClusterError>
Update a peer’s state.
Sourcepub fn heartbeat(&self, node_id: &str) -> Result<(), ClusterError>
pub fn heartbeat(&self, node_id: &str) -> Result<(), ClusterError>
Record a heartbeat from a peer.
Sourcepub fn list_peers(&self) -> Vec<(NodeId, NodeState, NodePlatform)>
pub fn list_peers(&self) -> Vec<(NodeId, NodeState, NodePlatform)>
List all peers with their states.
Sourcepub fn count_by_state(&self, state: &NodeState) -> usize
pub fn count_by_state(&self, state: &NodeState) -> usize
Count peers by state.
Sourcepub fn add_peer_with_tree(
&self,
peer: PeerNode,
tree: &Mutex<ResourceTree>,
) -> Result<(), ClusterError>
pub fn add_peer_with_tree( &self, peer: PeerNode, tree: &Mutex<ResourceTree>, ) -> Result<(), ClusterError>
Add a peer and optionally create a resource tree node.
Sourcepub fn active_peers(&self) -> Vec<NodeId> ⓘ
pub fn active_peers(&self) -> Vec<NodeId> ⓘ
Get all active peer node IDs.
Auto Trait Implementations§
impl !Freeze for ClusterMembership
impl !RefUnwindSafe for ClusterMembership
impl Send for ClusterMembership
impl Sync for ClusterMembership
impl Unpin for ClusterMembership
impl UnsafeUnpin for ClusterMembership
impl UnwindSafe for ClusterMembership
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