Skip to main content

FileTransitionLog

Struct FileTransitionLog 

Source
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

Source

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.

Source

pub fn path(&self) -> &Path

Path of the backing file.

Source

pub fn sync_on_append(&self) -> bool

Whether every append is fsynced. Enabled by default.

Source

pub fn set_sync_on_append(&mut self, value: bool)

Turns per-append fsync on or off — see the durability notes.

Trait Implementations§

Source§

impl Debug for FileTransitionLog

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl TransitionLogStore for FileTransitionLog

Source§

fn append_log_entry(&mut self, entry: &str) -> Result<(), LinkError>

Appends one entry. Entries never contain newlines.
Source§

fn read_log_entries(&mut self) -> Result<Vec<String>, LinkError>

Reads every entry back, oldest first.
Source§

fn flush_log(&mut self) -> Result<(), LinkError>

Makes every appended entry durable.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.