Expand description
Append-only framed journal.
Persistence is kept orthogonal to serialization. The journal moves opaque
versioned, checksummed frames to and from a file and handles the durability
concerns — append, fsync, bounded recovery, and recovery of a torn trailing
frame after a crash.
How a record turns into a payload is entirely the FrameCodec’s business, so
the Raft log store can frame protobuf while the WAL engine frames JSON over the
exact same code.
Structs§
- Journal
Writer - An append handle over a single journal file.
- Json
Codec - JSON frame codec for any owned, serde-serializable record.
Constants§
- MAX_
FRAME_ PAYLOAD_ BYTES - Maximum encoded payload accepted from disk or written as one journal frame.
Traits§
- Frame
Codec - Serialization seam: how one record becomes a frame payload and back.
Functions§
- decode_
frames - Decode framed records from an in-memory buffer, returning the records and the byte length of the valid (fully-written) prefix. A torn trailing frame ends the scan.
- migrate_
legacy - Migrate the legacy
[length][payload]journal format to the current checksummed format, retaining a hard-linked.v0.bakrollback copy. - replay
- Read every record from
path, decoding withC. A torn trailing frame left by a crash mid-write is truncated away and ignored, leaving the file at its last clean record boundary. - replay_
each - Stream every valid record from
paththroughvisitwithout retaining the entire journal in memory. A torn trailing frame is truncated with the same recovery semantics asreplay. - truncate_
to - Truncate
pathtovalid_lenbytes, dropping a torn trailing frame, thenfsync.