Skip to main content

TimedLog

Struct TimedLog 

Source
pub struct TimedLog<L, M> { /* private fields */ }
Expand description

Keeps revision|unix milliseconds in a second log for every record appended to inner. Records and their format are unchanged, so an engine or a backup never needs to know this decorator exists, and the cost is one more append and flush.

The record is written and flushed first, so a crash can lose a timestamp but never leave one for a record that is not there. A commit without a timestamp makes a restore pick an earlier revision. Time never runs backwards in a timeline: a clock that steps back repeats the latest time instead.

Implementations§

Source§

impl<L: TransitionLogStore, M: TransitionLogStore> TimedLog<L, M>

Source

pub fn new(inner: L, timeline: M) -> Result<Self, LinkError>

Timestamps from the system clock.

Source

pub fn with_clock( inner: L, timeline: M, clock: impl FnMut() -> u64 + Send + 'static, ) -> Result<Self, LinkError>

Timestamps from clock, in the milliseconds revision_at will be asked for.

Trait Implementations§

Source§

impl<L: ReplaceableTransitionLogStore, M: TransitionLogStore> ReplaceableTransitionLogStore for TimedLog<L, M>

Compaction does not touch the timeline: its checkpoint repeats a revision the timeline already holds, and revisions it dropped are then refused by a restore.

Source§

fn supports_replacement(&self) -> bool

Dynamic adapters can expose the capability only when their inner log can.
Source§

fn replace_log_entries(&mut self, entries: &[String]) -> Result<bool, LinkError>

Returns false when an identical committed journal needs no replacement. Pending unflushed records must be rejected before changing durable state.
Source§

impl<L: TransitionLogStore, M: TransitionLogStore> TransitionLogStore for TimedLog<L, M>

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.
Source§

fn supports_durable_flush(&self) -> bool

Whether flush requests persistent storage. Custom/volatile logs default to false; this describes an adapter, not the reliability of its hardware.
Source§

fn supports_compaction(&self) -> bool

Whether compact_log_entries can rewrite the durable journal. Retention uses it to bound the journal on disk; logs without it keep every entry, as before.
Source§

fn compact_log_entries(&mut self, entries: &[String]) -> Result<(), LinkError>

Atomically and durably replaces every entry with entries, the retained journal. After a crash the log holds either the old or the new journal, never a mixture. Called only between transactions and only when supports_compaction is true.

Auto Trait Implementations§

§

impl<L, M> !RefUnwindSafe for TimedLog<L, M>

§

impl<L, M> !Sync for TimedLog<L, M>

§

impl<L, M> !UnwindSafe for TimedLog<L, M>

§

impl<L, M> Freeze for TimedLog<L, M>
where L: Freeze, M: Freeze,

§

impl<L, M> Send for TimedLog<L, M>
where L: Send, M: Send,

§

impl<L, M> Unpin for TimedLog<L, M>
where L: Unpin, M: Unpin,

§

impl<L, M> UnsafeUnpin for TimedLog<L, M>
where L: UnsafeUnpin, M: UnsafeUnpin,

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> Same for T

Source§

type Output = T

Should always be Self
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, !>

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.