Skip to main content

Crate nano_wal

Crate nano_wal 

Source
Expand description

A concurrent Write-Ahead Log (WAL) with CAS-based segment rotation and coalesced preadv reads.

§Features

  • Lock-free segment rotation via ArcSwap + CAS
  • Concurrent reads via dup’d file descriptors (preadv)
  • Coalesced batch reads for minimal syscalls
  • Clock-aligned segment expiration windows
  • Vectored writes (writev) for batch appends

§Examples

use nano_wal::{Wal, WalOptions};
use std::time::Duration;

let options = WalOptions {
    retention: Duration::from_secs(3600),
    segment_duration: Duration::from_secs(600),
};
let wal = Wal::new("/tmp/my_wal", "stream-0", options).unwrap();

let now_ms = 1711234567890i64;
let entry = wal.append(None, b"hello world", now_ms, false).unwrap();

Structs§

Bytes
Re-exported for callers who need to hold segment read fds. A cheaply cloneable and sliceable chunk of contiguous memory.
CleanupResult
DeletedSegment
EntryRef
EntryRef returned from append operations.
ReadDescriptor
Descriptor for a single record to be read from a segment.
Record
A parsed record read from the WAL.
Segment
A single WAL segment file with concurrent read/write support.
Wal
WalOptions
WriteEntry
A single entry for batch append operations.

Enums§

WalError

Functions§

read_batch
Read a batch of records, coalescing contiguous reads on the same fd into single preadv syscalls.

Type Aliases§

Result