pub struct SyncState {
pub node_id: Uuid,
pub clock: VectorClock,
pub peers: HashMap<Uuid, PeerState>,
pub config: SyncConfig,
/* private fields */
}Expand description
The synchronization state for a node.
Fields§
§node_id: UuidThis node’s ID
clock: VectorClockCurrent vector clock
peers: HashMap<Uuid, PeerState>Known peers
config: SyncConfigConfiguration
Implementations§
Source§impl SyncState
impl SyncState
Sourcepub fn with_config(node_id: Uuid, config: SyncConfig) -> Self
pub fn with_config(node_id: Uuid, config: SyncConfig) -> Self
Create with custom configuration.
Sourcepub fn register_peer(&mut self, peer_id: Uuid, clock: VectorClock)
pub fn register_peer(&mut self, peer_id: Uuid, clock: VectorClock)
Register a new peer.
Sourcepub fn register_peer_with_info(&mut self, info: PeerInfo, clock: VectorClock)
pub fn register_peer_with_info(&mut self, info: PeerInfo, clock: VectorClock)
Register a peer with full info.
Sourcepub fn remove_peer(&mut self, peer_id: &Uuid)
pub fn remove_peer(&mut self, peer_id: &Uuid)
Remove a peer.
Sourcepub fn get_peer_mut(&mut self, peer_id: &Uuid) -> Option<&mut PeerState>
pub fn get_peer_mut(&mut self, peer_id: &Uuid) -> Option<&mut PeerState>
Get a mutable reference to a peer’s state.
Sourcepub fn create_hello(&mut self, name: Option<String>) -> SyncMessage
pub fn create_hello(&mut self, name: Option<String>) -> SyncMessage
Create a hello message.
Sourcepub fn create_delta_request(&mut self, since_clock: VectorClock) -> SyncMessage
pub fn create_delta_request(&mut self, since_clock: VectorClock) -> SyncMessage
Create a delta request message.
Sourcepub fn create_delta_response(
&mut self,
deltas: DeltaBatch,
has_more: bool,
) -> SyncMessage
pub fn create_delta_response( &mut self, deltas: DeltaBatch, has_more: bool, ) -> SyncMessage
Create a delta response message.
Sourcepub fn create_full_state(&mut self, state: GA3) -> SyncMessage
pub fn create_full_state(&mut self, state: GA3) -> SyncMessage
Create a full state message.
Sourcepub fn create_heartbeat(&mut self) -> SyncMessage
pub fn create_heartbeat(&mut self) -> SyncMessage
Create a heartbeat message.
Sourcepub fn create_ack(&mut self, message_id: u64) -> SyncMessage
pub fn create_ack(&mut self, message_id: u64) -> SyncMessage
Create an acknowledgment message.
Sourcepub fn create_goodbye(&mut self) -> SyncMessage
pub fn create_goodbye(&mut self) -> SyncMessage
Create a goodbye message.
Sourcepub fn handle_message(&mut self, message: &SyncMessage) -> Option<SyncMessage>
pub fn handle_message(&mut self, message: &SyncMessage) -> Option<SyncMessage>
Handle an incoming message from a peer.
Sourcepub fn stale_peers(&self) -> Vec<Uuid>
pub fn stale_peers(&self) -> Vec<Uuid>
Get list of stale peers that should be checked.
Sourcepub fn peers_needing_heartbeat(&self) -> Vec<Uuid>
pub fn peers_needing_heartbeat(&self) -> Vec<Uuid>
Get peers that need heartbeats.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SyncState
impl RefUnwindSafe for SyncState
impl Send for SyncState
impl Sync for SyncState
impl Unpin for SyncState
impl UnsafeUnpin for SyncState
impl UnwindSafe for SyncState
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