Trait okaywal::LogManager

source ·
pub trait LogManager: Send + Sync + Debug + 'static {
    // Required methods
    fn recover(&mut self, entry: &mut Entry<'_>) -> Result<()>;
    fn checkpoint_to(
        &mut self,
        last_checkpointed_id: EntryId,
        checkpointed_entries: &mut SegmentReader,
        wal: &WriteAheadLog
    ) -> Result<()>;

    // Provided method
    fn should_recover_segment(
        &mut self,
        _segment: &RecoveredSegment
    ) -> Result<Recovery> { ... }
}
Expand description

Customizes recovery and checkpointing behavior for a WriteAheadLog.

Required Methods§

source

fn recover(&mut self, entry: &mut Entry<'_>) -> Result<()>

Invoked once for each entry contained in all recovered segments within a WriteAheadLog.

Entry::read_chunk() can be used to read each chunk of data that was written via EntryWriter::write_chunk. The order of chunks is guaranteed to be the same as the order they were written in.

source

fn checkpoint_to( &mut self, last_checkpointed_id: EntryId, checkpointed_entries: &mut SegmentReader, wal: &WriteAheadLog ) -> Result<()>

Invoked each time the WriteAheadLog is ready to recycle and reuse segment files.

last_checkpointed_id is the id of the last entry that is being checkedpointed and removed from the log. If needed, checkpointed_entries can be used to iterate over all entries that are being checkpointed.

Shortly after function returns, the entries stored within the file being checkpointed will no longer be accessible. To ensure ACID compliance of the underlying storage layer, all necessary changes must be fully synchronized to the underlying storage medium before this function call returns.

Provided Methods§

source

fn should_recover_segment( &mut self, _segment: &RecoveredSegment ) -> Result<Recovery>

When recovering a WriteAheadLog, this function is called for each segment as it is read. To allow the segment to have its data recovered, return Recovery::Recover. If you wish to abandon the data contained in the segment, return Recovery::Abandon.

Implementors§