pub struct StateReplicationManager { /* private fields */ }Expand description
Replicates stream state across nodes using a gossip protocol.
Each node periodically gossips its state digest to a random subset of peers; peers that detect a divergence request the full state payload.
Implementations§
Source§impl StateReplicationManager
impl StateReplicationManager
Sourcepub fn new(node_id: impl Into<String>, config: ReplicationConfig) -> Self
pub fn new(node_id: impl Into<String>, config: ReplicationConfig) -> Self
Creates a new replication manager for the given node.
Sourcepub fn update_local_state(&self, state: Vec<u8>)
pub fn update_local_state(&self, state: Vec<u8>)
Updates the local state, recomputing the digest.
Sourcepub fn produce_gossip(&self) -> Vec<GossipMessage>
pub fn produce_gossip(&self) -> Vec<GossipMessage>
Produces gossip messages for the current round (up to fanout peers).
Returns the list of gossip messages to send.
Sourcepub fn receive_gossip(&self, msg: GossipMessage) -> StateResult<bool>
pub fn receive_gossip(&self, msg: GossipMessage) -> StateResult<bool>
Receives and processes an incoming gossip message.
Returns true if a state synchronisation was triggered (digest differed).
Sourcepub fn local_digest(&self) -> String
pub fn local_digest(&self) -> String
Returns the current local state digest.
Sourcepub fn stats(&self) -> ReplicationStats
pub fn stats(&self) -> ReplicationStats
Returns replication statistics.
Sourcepub fn stale_peers(&self) -> Vec<String>
pub fn stale_peers(&self) -> Vec<String>
Returns IDs of stale peers (not heard from in stale_rounds rounds).
Auto Trait Implementations§
impl Freeze for StateReplicationManager
impl !RefUnwindSafe for StateReplicationManager
impl Send for StateReplicationManager
impl Sync for StateReplicationManager
impl Unpin for StateReplicationManager
impl UnsafeUnpin for StateReplicationManager
impl !UnwindSafe for StateReplicationManager
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.