Skip to main content

LogStore

Struct LogStore 

Source
pub struct LogStore { /* private fields */ }
Expand description

The default store: every update is appended to a log file and synced before the service replies, and every so often the whole state is written as a checkpoint and the log emptied.

The directory holds naming.ckp, the last checkpoint, and naming.log, the updates since. Both are text with one record per line, starting with a header rustorb-naming 1 GENERATION:

rustorb-naming 1 3
context NameService
bind NameService o app.kind IOR:0100...
bind NameService c sub IOR:0100...
unbind NameService app.kind
destroy 5f3a9c0e12ab44d1

A name component is written in the stringified name form (id.kind, with \ escapes), and %, spaces and control characters in it as %XX. A checkpoint ends with an end line.

A checkpoint is written to a temporary file, synced and renamed over naming.ckp; then the log is started again with the checkpoint’s generation. At load, a log of an older generation than the checkpoint (a crash between the two steps) is ignored, and a last line without its newline (a crash while appending) is dropped.

Implementations§

Source§

impl LogStore

Source

pub fn new(dir: impl Into<PathBuf>) -> LogStore

A store in the directory dir, created if needed. A checkpoint is written every 1000 updates.

Source

pub fn checkpoint_every(self, records: usize) -> LogStore

Writes a checkpoint after records updates (at least 1).

Source

pub fn checkpoint_interval(self, interval: Duration) -> LogStore

Also writes a checkpoint at the first update after interval has passed since the last one.

Source

pub fn dir(&self) -> &Path

The directory of the files.

Trait Implementations§

Source§

impl Debug for LogStore

Source§

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

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

impl Store for LogStore

Source§

fn load(&mut self) -> Result<Snapshot>

The state to start from. Called once, before anything else.
Source§

fn record(&mut self, change: &Change) -> Result<()>

Records change. When this returns, the change must survive a crash; an error fails the operation with PERSIST_STORE.
Source§

fn checkpoint(&mut self, state: &Snapshot) -> Result<()>

Called after each update with the state that includes it, so that the store can write a checkpoint when it sees fit.

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

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, !>

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

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more