pub struct WalReader { /* private fields */ }Expand description
Reads entries from all WAL segments in a directory.
Segments are processed in ascending segment_id order. CRC32
checksums are validated for every entry.
Implementations§
Source§impl WalReader
impl WalReader
Sourcepub fn read_all(&self) -> RaftResult<Vec<LogEntry>>
pub fn read_all(&self) -> RaftResult<Vec<LogEntry>>
Read all entries from all segments, validating CRC for every entry.
Returns an error if any corruption or CRC mismatch is detected. Accepts both WAL v1 and WAL v2 segments transparently.
Sourcepub fn recover(&self) -> RaftResult<Vec<LogEntry>>
pub fn recover(&self) -> RaftResult<Vec<LogEntry>>
Recover entries from all segments, tolerating a partial or corrupted final entry.
Complete, CRC-valid entries are returned. If the very last entry of the very last segment is incomplete or has a bad CRC it is silently discarded (crash recovery). Corruption in the middle of a segment still returns an error.
Uses CorruptionPolicy::TruncateToLastGood for backward
compatibility.
Sourcepub fn recover_with_policy(
&self,
policy: CorruptionPolicy,
) -> RaftResult<(Vec<LogEntry>, WalDiagnostics)>
pub fn recover_with_policy( &self, policy: CorruptionPolicy, ) -> RaftResult<(Vec<LogEntry>, WalDiagnostics)>
Recover entries with an explicit CorruptionPolicy.
Returns the recovered entries together with WalDiagnostics
describing what was found.