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.
A crash can therefore only ever truncate the file mid-line.
open discards such a torn tail before
the log is used again — otherwise the next append would be glued
onto the fragment and lost with it — and
read_log_entries ignores
one defensively. A torn write costs at most the single transition
that was in flight.
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 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.