pub struct GossipEngine { /* private fields */ }Expand description
The gossip engine manages cluster membership and failure detection.
Implementations§
Source§impl GossipEngine
impl GossipEngine
Sourcepub fn new(
local_id: NodeId,
local_addr: SocketAddr,
config: GossipConfig,
event_tx: Sender<GossipEvent>,
) -> Self
pub fn new( local_id: NodeId, local_addr: SocketAddr, config: GossipConfig, event_tx: Sender<GossipEvent>, ) -> Self
Creates a new gossip engine.
Sourcepub fn members(&self) -> impl Iterator<Item = &MemberState>
pub fn members(&self) -> impl Iterator<Item = &MemberState>
Returns all known members.
Sourcepub fn alive_count(&self) -> usize
pub fn alive_count(&self) -> usize
Returns the number of alive members (excluding self).
Sourcepub fn add_seed(&mut self, id: NodeId, addr: SocketAddr)
pub fn add_seed(&mut self, id: NodeId, addr: SocketAddr)
Adds a seed node to bootstrap cluster discovery.
Sourcepub async fn handle_message(
&mut self,
msg: GossipMessage,
from: SocketAddr,
) -> Option<GossipMessage>
pub async fn handle_message( &mut self, msg: GossipMessage, from: SocketAddr, ) -> Option<GossipMessage>
Handles an incoming gossip message.
Sourcepub fn tick(&mut self) -> Option<(SocketAddr, GossipMessage)>
pub fn tick(&mut self) -> Option<(SocketAddr, GossipMessage)>
Runs one protocol period: probe a random node.
Sourcepub fn create_join_message(&self) -> GossipMessage
pub fn create_join_message(&self) -> GossipMessage
Creates a join message to send to a seed node.
Auto Trait Implementations§
impl Freeze for GossipEngine
impl RefUnwindSafe for GossipEngine
impl Send for GossipEngine
impl Sync for GossipEngine
impl Unpin for GossipEngine
impl UnwindSafe for GossipEngine
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