pub struct LogCompactor;Expand description
Handles compaction of the Raft log by replacing committed entries with a snapshot, thereby bounding log growth.
Implementations§
Source§impl LogCompactor
impl LogCompactor
Sourcepub fn compact(log: &mut Vec<LogEntry>, snapshot_idx: u64) -> Snapshot
pub fn compact(log: &mut Vec<LogEntry>, snapshot_idx: u64) -> Snapshot
Compact the Raft log up to (and including) snapshot_idx.
All log entries with index <= snapshot_idx are removed from log.
Returns a Snapshot that captures the term of the last removed entry
(or 0 if no entry was found at snapshot_idx) and an empty state-data
payload. Callers are expected to replace the payload with the actual
serialised state-machine snapshot before persisting.
§Arguments
log- Mutable reference to the Raft log.snapshot_idx- The log index up to which compaction should proceed.
§Returns
A Snapshot representing the compaction boundary.
Sourcepub fn install_snapshot(log: &mut Vec<LogEntry>, snapshot: &Snapshot) -> bool
pub fn install_snapshot(log: &mut Vec<LogEntry>, snapshot: &Snapshot) -> bool
Apply a received snapshot to a log: truncate the entire log if the snapshot is newer than all existing entries.
Returns true if the snapshot was applied (log was truncated), false
if the log already has entries beyond the snapshot (snapshot is stale).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for LogCompactor
impl RefUnwindSafe for LogCompactor
impl Send for LogCompactor
impl Sync for LogCompactor
impl Unpin for LogCompactor
impl UnsafeUnpin for LogCompactor
impl UnwindSafe for LogCompactor
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
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>
T in a tonic::Request