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.
Peer-add rate limiting is initialised from
ClusterConfig::peer_add_rate_config (defaults: 1 per source
per 100 ms).
Sourcepub fn facts(&self) -> &NodeFactsCache
pub fn facts(&self) -> &NodeFactsCache
Verified node facts (local and peers) with TTL (card mesh-placement-03).
Sourcepub fn with_chain(self, cm: Arc<ChainManager>) -> Self
pub fn with_chain(self, cm: Arc<ChainManager>) -> Self
Attach a chain manager for audit logging (builder style).
Sourcepub fn with_gate(self, gate: Arc<GovernanceGate>) -> Self
pub fn with_gate(self, gate: Arc<GovernanceGate>) -> Self
Attach a governance gate for policy enforcement (builder style).
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 from the same source (builder style).
Duration::ZERO disables rate limiting (used by unit tests).
Non-zero intervals configure a per-source limit of 1 addition
per interval. Prefer Self::with_peer_add_rate_limit for
multi-count windows.
Sourcepub fn with_peer_add_rate_limit(self, config: RateLimitConfig) -> Self
pub fn with_peer_add_rate_limit(self, config: RateLimitConfig) -> Self
Configure the per-source add_peer rate limit (WEFT-148).
Sourcepub fn peer_add_rate_limit(&self) -> RateLimitConfig
pub fn peer_add_rate_limit(&self) -> RateLimitConfig
Current peer-add rate-limit configuration.
Sourcepub fn peer_add_source_key(peer: &PeerNode) -> &str
pub fn peer_add_source_key(peer: &PeerNode) -> &str
Resolve the rate-limit source key for a peer.
Prefers network address when present (so one host flooding many
node IDs still hits the same bucket); falls back to peer id.
Sourcepub fn with_persist_path(self, path: impl AsRef<Path>) -> Self
pub fn with_persist_path(self, path: impl AsRef<Path>) -> Self
Enable peer persistence at the given path (builder style).
If the file exists and is readable, peers are rehydrated into the
in-memory map so joins survive kernel restarts. Parse errors log a
warning and leave the map empty. Subsequent mutations write back to
the same path via Self::persist.
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 per source (WEFT-148): by default at most one
addition per source per 100 ms. Source key is the peer’s network
address when set, otherwise its node id. Thresholds are
configurable via ClusterConfig /
Self::with_peer_add_rate_limit.
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 add_peer_checked(
&self,
peer: PeerNode,
revocation_list: &RevocationList,
) -> Result<(), ClusterError>
pub fn add_peer_checked( &self, peer: PeerNode, revocation_list: &RevocationList, ) -> Result<(), ClusterError>
Register a peer node, checking the revocation list first.
If the peer’s ID appears in the revocation list, the add is
rejected with ClusterError::AuthFailed.
Sourcepub fn active_peers(&self) -> Vec<NodeId> ⓘ
pub fn active_peers(&self) -> Vec<NodeId> ⓘ
Get all active peer node IDs.
Sourcepub fn expire_unverified(&self, max_age: Duration) -> usize
pub fn expire_unverified(&self, max_age: Duration) -> usize
Drop Unverified peers not heard from for max_age. They are not
members, so nothing else ages them out (a peer that never sends a
Left, or whose route vanished without an event, would linger).
Returns how many were dropped.
Sourcepub fn apply_mesh_peer_event(
&self,
event: &MeshPeerEvent,
) -> Result<bool, ClusterError>
pub fn apply_mesh_peer_event( &self, event: &MeshPeerEvent, ) -> Result<bool, ClusterError>
Apply a live mesh peer event to membership atomically (WEFT-120).
Mesh is the authority for connect/health; this path upserts peers
without the operator-facing add_peer rate limit (mesh already
authenticated the session). A single event produces one consistent
membership mutation + one persist.
Returns true when membership changed.
Sourcepub fn spawn_mesh_peer_listener(self: &Arc<Self>, rx: Receiver<MeshPeerEvent>)
pub fn spawn_mesh_peer_listener(self: &Arc<Self>, rx: Receiver<MeshPeerEvent>)
Drain a mesh peer-event receiver and apply each event (WEFT-120).
Spawns a background task. Intended for boot when ClusterService
is not available (mesh-only builds) or as a shared membership
path. Prefer ClusterService::spawn_mesh_peer_listener when
the cluster feature is on so ruvector nodes stay in sync too.
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
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> ⓘ
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> ⓘ
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