pub struct MembershipSnapshot {
pub members: BTreeSet<u32>,
pub learners: BTreeSet<u32>,
pub committed_index: u64,
}Expand description
A point-in-time snapshot of committed cluster membership.
Delivered via crate::EmbeddedEngine::watch_membership whenever a ConfChange
entry commits. The snapshot reflects the membership state after the
change has been applied, so borrow() always returns a consistent view.
§Idempotency
committed_index is the Raft log index of the ConfChange entry that
triggered this snapshot. It is strictly monotonically increasing across
snapshots and can be used as an idempotency key:
if snapshot.committed_index <= self.last_applied {
return; // already handled
}
self.last_applied = snapshot.committed_index;
scheduler.rebalance(&snapshot);§Diff computation
No diff fields are included. Because watch::channel is lossy (only the
latest value is retained), a diff embedded in the snapshot could be stale
if the receiver is slow and skips an intermediate change. Callers that
need a diff should compute it against their own previous snapshot:
let prev = std::mem::replace(&mut self.prev_snapshot, snapshot.clone());
let joined: BTreeSet<_> = snapshot.members.difference(&prev.members).copied().collect();
let left: BTreeSet<_> = prev.members.difference(&snapshot.members).copied().collect();Fields§
§members: BTreeSet<u32>Current voting members (Follower / Leader role, Active status).
learners: BTreeSet<u32>Current non-voting learners (Learner role, Promotable or ReadOnly status).
committed_index: u64Raft log index of the ConfChange entry that produced this snapshot. Monotonically increasing; use as an idempotency key.
Trait Implementations§
Source§impl Clone for MembershipSnapshot
impl Clone for MembershipSnapshot
Source§fn clone(&self) -> MembershipSnapshot
fn clone(&self) -> MembershipSnapshot
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MembershipSnapshot
impl Debug for MembershipSnapshot
Source§impl Default for MembershipSnapshot
impl Default for MembershipSnapshot
Source§fn default() -> MembershipSnapshot
fn default() -> MembershipSnapshot
Source§impl PartialEq for MembershipSnapshot
impl PartialEq for MembershipSnapshot
Source§fn eq(&self, other: &MembershipSnapshot) -> bool
fn eq(&self, other: &MembershipSnapshot) -> bool
self and other values to be equal, and is used by ==.impl Eq for MembershipSnapshot
impl StructuralPartialEq for MembershipSnapshot
Auto Trait Implementations§
impl Freeze for MembershipSnapshot
impl RefUnwindSafe for MembershipSnapshot
impl Send for MembershipSnapshot
impl Sync for MembershipSnapshot
impl Unpin for MembershipSnapshot
impl UnsafeUnpin for MembershipSnapshot
impl UnwindSafe for MembershipSnapshot
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request