Skip to main content

MembershipCore

Struct MembershipCore 

Source
pub struct MembershipCore<P> { /* private fields */ }
Expand description

The pure membership compute core: the SWIM state machine over a keyed peer map, driven by heartbeats and a logical clock. Emits PeerChangeEvents.

Implementations§

Source§

impl<P: Ord + Clone> MembershipCore<P>

Source

pub fn new(config: MembershipConfig) -> Self

Source

pub fn alive_set(&self) -> BTreeSet<P>

The current alive peer set (the reactive PeerSet).

Source

pub fn state(&self, peer: &P) -> Option<PeerState>

The state of a known peer.

Source

pub fn join(&mut self, peer: P, now: u64) -> Vec<PeerChangeEvent<P>>

Join a peer (or refresh a re-joining one): Alive with a fresh detector.

Source

pub fn heartbeat(&mut self, peer: P, now: u64) -> Vec<PeerChangeEvent<P>>

Record a heartbeat. An unknown peer is a join; a Suspect/Dead peer returns to Alive (SWIM refutation).

Source

pub fn leave(&mut self, peer: P, _now: u64) -> Vec<PeerChangeEvent<P>>

Graceful departure.

Source

pub fn tick(&mut self, now: u64) -> Vec<PeerChangeEvent<P>>

Advance the clock: escalate Alive → Suspect (phi crossed) and Suspect → Dead (timeout elapsed).

Auto Trait Implementations§

§

impl<P> Freeze for MembershipCore<P>
where BTreeMap<P, PeerRecord>: Freeze,

§

impl<P> RefUnwindSafe for MembershipCore<P>
where BTreeMap<P, PeerRecord>: RefUnwindSafe,

§

impl<P> Send for MembershipCore<P>
where BTreeMap<P, PeerRecord>: Send,

§

impl<P> Sync for MembershipCore<P>
where BTreeMap<P, PeerRecord>: Sync,

§

impl<P> Unpin for MembershipCore<P>
where BTreeMap<P, PeerRecord>: Unpin,

§

impl<P> UnsafeUnpin for MembershipCore<P>
where BTreeMap<P, PeerRecord>: UnsafeUnpin,

§

impl<P> UnwindSafe for MembershipCore<P>
where BTreeMap<P, PeerRecord>: UnwindSafe,

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