pub struct FileTransitionLog { /* private fields */ }Expand description
Append-only, line-oriented transitions log backed by a single file.
§Durability
With sync_on_append enabled (the default) every
append_log_entry returns
only after the entry has reached stable storage, which is what makes
the write-ahead ordering of the transactions layer meaningful: a
transition is always durable before the data-store write it
describes is reported as committed. Disabling it trades that
guarantee for throughput — the log is then durable only as far as
the last flush_log.
An interrupted append can leave a partial final line. Opening the log, or reading, appending or flushing after a writer I/O error, repairs that suffix before proceeding. A failed repair is retried on the next operation. Complete records remain intact, including records written before an error was returned; callers must discover an uncertain transaction’s outcome rather than blindly retry it. Repair scans backwards with an 8 KiB buffer; successful operations do not rescan. This framing protocol assumes storage honors flush and does not prove device-sector atomicity after power loss.
Implementations§
Source§impl FileTransitionLog
impl FileTransitionLog
Sourcepub fn open<P: AsRef<Path>>(path: P) -> Result<Self, LinkError>
pub fn open<P: AsRef<Path>>(path: P) -> Result<Self, LinkError>
Opens (creating if needed) the log at path, discarding a
trailing entry left half-written by a crash.
Sourcepub fn open_exclusive<P: AsRef<Path>>(path: P) -> Result<Self, LinkError>
pub fn open_exclusive<P: AsRef<Path>>(path: P) -> Result<Self, LinkError>
Holds the conventional sidecar lock until drop. Contention fails fast; all writers must follow the same advisory locking convention.
Sourcepub fn sync_on_append(&self) -> bool
pub fn sync_on_append(&self) -> bool
Whether every append is fsynced. Enabled by default.
Sourcepub fn set_sync_on_append(&mut self, value: bool)
pub fn set_sync_on_append(&mut self, value: bool)
Turns per-append fsync on or off — see the durability notes.