Skip to main content

ClusterMembership

Struct ClusterMembership 

Source
pub struct ClusterMembership { /* private fields */ }

Implementations§

Source§

impl ClusterMembership

Source

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).

Source

pub fn facts(&self) -> &NodeFactsCache

Verified node facts (local and peers) with TTL (card mesh-placement-03).

Source

pub fn with_chain(self, cm: Arc<ChainManager>) -> Self

Attach a chain manager for audit logging (builder style).

Source

pub fn with_gate(self, gate: Arc<GovernanceGate>) -> Self

Attach a governance gate for policy enforcement (builder style).

Source

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.

Source

pub fn with_peer_add_rate_limit(self, config: RateLimitConfig) -> Self

Configure the per-source add_peer rate limit (WEFT-148).

Source

pub fn peer_add_rate_limit(&self) -> RateLimitConfig

Current peer-add rate-limit configuration.

Source

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.

Source

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.

Source

pub fn config(&self) -> &ClusterConfig

Get the cluster configuration.

Source

pub fn local_node_id(&self) -> &str

Get this node’s ID.

Source

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.

Source

pub fn remove_peer(&self, node_id: &str) -> Result<PeerNode, ClusterError>

Remove a peer node.

Source

pub fn update_state( &self, node_id: &str, new_state: NodeState, ) -> Result<(), ClusterError>

Update a peer’s state.

Source

pub fn heartbeat(&self, node_id: &str) -> Result<(), ClusterError>

Record a heartbeat from a peer.

Source

pub fn get_peer(&self, node_id: &str) -> Option<PeerNode>

Get a snapshot of a peer’s state.

Source

pub fn list_peers(&self) -> Vec<(NodeId, NodeState, NodePlatform)>

List all peers with their states.

Source

pub fn count_by_state(&self, state: &NodeState) -> usize

Count peers by state.

Source

pub fn len(&self) -> usize

Count total peers.

Source

pub fn is_empty(&self) -> bool

Check if cluster has no peers.

Source

pub fn add_peer_with_tree( &self, peer: PeerNode, tree: &Mutex<ResourceTree>, ) -> Result<(), ClusterError>

Add a peer and optionally create a resource tree node.

Source

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.

Source

pub fn active_peers(&self) -> Vec<NodeId> ⓘ

Get all active peer node IDs.

Source

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.

Source

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.

Source

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Pointee for T

Source§

type Pointer = u32

Source§

fn debug( pointer: <T as Pointee>::Pointer, f: &mut Formatter<'_>, ) -> Result<(), Error>

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more