pub struct ReplicationEngine { /* private fields */ }Expand description
The main replication engine.
Implementations§
Source§impl ReplicationEngine
impl ReplicationEngine
Sourcepub fn new(local_node: NodeInfo, config: ReplicationConfig) -> Self
pub fn new(local_node: NodeInfo, config: ReplicationConfig) -> Self
Create a new replication engine.
Sourcepub fn current_term(&self) -> u64
pub fn current_term(&self) -> u64
Get the current term.
Sourcepub fn cluster_state(&self) -> ClusterState
pub fn cluster_state(&self) -> ClusterState
Get cluster state.
Sourcepub fn cluster_stats(&self) -> ClusterStats
pub fn cluster_stats(&self) -> ClusterStats
Get cluster stats.
Sourcepub fn remove_peer(&self, peer_id: &NodeId) -> Result<NodeInfo, ClusterError>
pub fn remove_peer(&self, peer_id: &NodeId) -> Result<NodeInfo, ClusterError>
Remove a peer from the cluster.
Sourcepub fn propose(&mut self, command: Command) -> Result<u64, ReplicationError>
pub fn propose(&mut self, command: Command) -> Result<u64, ReplicationError>
Propose a command to the cluster.
Sourcepub fn set(
&mut self,
key: impl Into<String>,
value: Vec<u8>,
) -> Result<u64, ReplicationError>
pub fn set( &mut self, key: impl Into<String>, value: Vec<u8>, ) -> Result<u64, ReplicationError>
Set a value (proposes to cluster if leader).
Sourcepub fn delete(
&mut self,
key: impl Into<String>,
) -> Result<u64, ReplicationError>
pub fn delete( &mut self, key: impl Into<String>, ) -> Result<u64, ReplicationError>
Delete a value (proposes to cluster if leader).
Sourcepub fn apply_committed(&self) -> Vec<CommandResult>
pub fn apply_committed(&self) -> Vec<CommandResult>
Apply committed entries to the state machine.
Sourcepub fn tick(&mut self) -> TickResult
pub fn tick(&mut self) -> TickResult
Process a tick of the event loop.
Sourcepub fn start_election(&self) -> VoteRequest
pub fn start_election(&self) -> VoteRequest
Start an election.
Sourcepub fn handle_vote_request(&self, request: &VoteRequest) -> VoteResponse
pub fn handle_vote_request(&self, request: &VoteRequest) -> VoteResponse
Handle a vote request.
Sourcepub fn handle_vote_response(&self, response: &VoteResponse) -> bool
pub fn handle_vote_response(&self, response: &VoteResponse) -> bool
Handle a vote response.
Sourcepub fn create_append_entries_for_peers(
&self,
) -> Vec<(NodeId, AppendEntriesRequest)>
pub fn create_append_entries_for_peers( &self, ) -> Vec<(NodeId, AppendEntriesRequest)>
Create append entries requests for all peers.
Sourcepub fn handle_append_entries(
&self,
request: &AppendEntriesRequest,
) -> AppendEntriesResponse
pub fn handle_append_entries( &self, request: &AppendEntriesRequest, ) -> AppendEntriesResponse
Handle an append entries request.
Sourcepub fn handle_append_entries_response(
&self,
peer_id: &NodeId,
response: &AppendEntriesResponse,
)
pub fn handle_append_entries_response( &self, peer_id: &NodeId, response: &AppendEntriesResponse, )
Handle an append entries response.
Sourcepub fn update_health(&self, health: NodeHealth)
pub fn update_health(&self, health: NodeHealth)
Update health for a node.
Sourcepub fn process_message(&mut self, message: Message) -> Option<Message>
pub fn process_message(&mut self, message: Message) -> Option<Message>
Process incoming message.
Sourcepub fn send_heartbeats(&self, transport: &dyn Transport)
pub fn send_heartbeats(&self, transport: &dyn Transport)
Send messages to peers using transport.
Sourcepub fn broadcast_election(&self, transport: &dyn Transport)
pub fn broadcast_election(&self, transport: &dyn Transport)
Broadcast election request.
Sourcepub fn config(&self) -> &ReplicationConfig
pub fn config(&self) -> &ReplicationConfig
Get the configuration.
Auto Trait Implementations§
impl Freeze for ReplicationEngine
impl !RefUnwindSafe for ReplicationEngine
impl Send for ReplicationEngine
impl Sync for ReplicationEngine
impl Unpin for ReplicationEngine
impl UnsafeUnpin for ReplicationEngine
impl !UnwindSafe for ReplicationEngine
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