Skip to main content

Crate raft_wal

Crate raft_wal 

Source
Expand description

§raft-wal

A minimal append-only WAL (Write-Ahead Log) optimized for Raft consensus.

  • Segment-based storage — log is split into segment files; compact() deletes old segments without rewriting.
  • CRC32C checksums — HW-accelerated integrity checks on every entry.
  • Raft-correct durability — metadata (term/vote) is always fsynced; log entries are buffered with opt-in RaftWal::sync.
  • Parallel recovery — segments are read and verified concurrently.
  • openraft integration — enable openraft-storage feature for RaftLogStorage implementation.

§Usage

use raft_wal::RaftWal;

let mut wal = RaftWal::open(dir.path()).unwrap();

wal.append(1, b"entry-1").unwrap();
wal.append(2, b"entry-2").unwrap();

let entries: Vec<_> = wal.iter().collect();
assert_eq!(entries.len(), 2);

wal.set_meta("vote", b"node-1").unwrap();
assert_eq!(wal.get_meta("vote"), Some(b"node-1".as_slice()));

Modules§

crc
CRC32C functions (hw-accelerated with std, software fallback in no_std). CRC32C abstraction — hardware-accelerated when std feature is enabled, software lookup table fallback for no_std.
impls
Optional trait implementations for Raft framework integration.
wire
Wire format serialization and parsing (no_std compatible). Wire format serialization and parsing (no_std compatible).

Structs§

Entry
A borrowed entry yielded by iterators over WAL entries.
GenericRaftWal
A generic append-only WAL optimized for Raft, parameterized over the storage backend.
StdStorage
A WalStorage backend that maps file names to a directory on the local filesystem.

Enums§

WalError
Errors returned by WAL operations.

Traits§

WalStorage
Trait abstracting file-like I/O for the WAL.

Type Aliases§

RaftWal
An append-only WAL optimized for Raft, backed by the local filesystem.
Result
Result type for WAL operations.