pub struct ReplicatedLog { /* private fields */ }Expand description
Replicated log with bounded capacity
Implementations§
Source§impl ReplicatedLog
impl ReplicatedLog
Sourcepub fn append(
&mut self,
term: u64,
command: impl Into<String>,
data: Vec<u8>,
) -> u64
pub fn append( &mut self, term: u64, command: impl Into<String>, data: Vec<u8>, ) -> u64
Append an entry and return its assigned index.
If the log exceeds max_size, the oldest entry is dropped (compaction).
Sourcepub fn last_index(&self) -> u64
pub fn last_index(&self) -> u64
Return the index of the last entry (0 if empty).
Sourcepub fn commit_up_to(&mut self, index: u64)
pub fn commit_up_to(&mut self, index: u64)
Advance the commit index up to index.
Sourcepub fn apply_committed(&mut self) -> Vec<LogEntry>
pub fn apply_committed(&mut self) -> Vec<LogEntry>
Advance last_applied to match commit_index and return applied entries.
Sourcepub fn get(&self, index: u64) -> Option<&LogEntry>
pub fn get(&self, index: u64) -> Option<&LogEntry>
Get entry by 1-based index (may not exist after compaction).
Sourcepub fn commit_index(&self) -> u64
pub fn commit_index(&self) -> u64
Return current commit index.
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
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request