pub struct ReplicatedLog { /* private fields */ }Expand description
The replicated log for Raft consensus.
Implementations§
Source§impl ReplicatedLog
impl ReplicatedLog
Sourcepub fn append_entries(&self, new_entries: Vec<LogEntry>) -> LogIndex
pub fn append_entries(&self, new_entries: Vec<LogEntry>) -> LogIndex
Append multiple entries.
Sourcepub fn get_range(&self, start: LogIndex, end: LogIndex) -> Vec<LogEntry>
pub fn get_range(&self, start: LogIndex, end: LogIndex) -> Vec<LogEntry>
Get entries in a range.
Sourcepub fn last_index(&self) -> LogIndex
pub fn last_index(&self) -> LogIndex
Get the last log index.
Sourcepub fn term_at(&self, index: LogIndex) -> Option<Term>
pub fn term_at(&self, index: LogIndex) -> Option<Term>
Get the term of an entry at a specific index.
Sourcepub fn commit_index(&self) -> LogIndex
pub fn commit_index(&self) -> LogIndex
Get the commit index.
Sourcepub fn set_commit_index(&self, index: LogIndex)
pub fn set_commit_index(&self, index: LogIndex)
Set the commit index.
Sourcepub fn last_applied(&self) -> LogIndex
pub fn last_applied(&self) -> LogIndex
Get the last applied index.
Sourcepub fn set_last_applied(&self, index: LogIndex)
pub fn set_last_applied(&self, index: LogIndex)
Set the last applied index.
Sourcepub fn has_entries_to_apply(&self) -> bool
pub fn has_entries_to_apply(&self) -> bool
Check if there are entries to apply.
Sourcepub fn next_to_apply(&self) -> Option<LogEntry>
pub fn next_to_apply(&self) -> Option<LogEntry>
Get the next entry to apply.
Sourcepub fn truncate_from(&self, index: LogIndex)
pub fn truncate_from(&self, index: LogIndex)
Truncate the log from a given index (inclusive).
Sourcepub fn is_up_to_date(
&self,
last_log_index: LogIndex,
last_log_term: Term,
) -> bool
pub fn is_up_to_date( &self, last_log_index: LogIndex, last_log_term: Term, ) -> bool
Check if a log is up-to-date compared to this log.
Sourcepub fn find_conflict(&self, entries: &[LogEntry]) -> Option<LogIndex>
pub fn find_conflict(&self, entries: &[LogEntry]) -> Option<LogIndex>
Find the conflict point when appending entries.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ReplicatedLog
impl RefUnwindSafe for ReplicatedLog
impl Send for ReplicatedLog
impl Sync for ReplicatedLog
impl Unpin for ReplicatedLog
impl UnsafeUnpin for ReplicatedLog
impl UnwindSafe for ReplicatedLog
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