Local

Struct Local 

Source
pub struct Local<T> { /* private fields */ }
Expand description

Durability implementation backed by a Commitlog on local storage.

The commitlog is constrained to store the canonical Txdata payload, where the generic parameter T is the type of the row data stored in the mutations section.

T is left generic in order to allow bypassing the ProductValue intermediate representation in the future.

Note, however, that instantiating T to a different type may require to change the log format version!

Implementations§

Source§

impl<T: Encode + Send + Sync + 'static> Local<T>

Source

pub fn open(root: CommitLogDir, rt: Handle, opts: Options) -> Result<Self>

Create a Local instance at the root directory.

The root directory must already exist.

Background tasks are spawned onto the provided tokio runtime.

Source

pub fn queue_depth(&self) -> u64

Inspect how many transactions added via Self::append_tx are pending to be applied to the underlying Commitlog.

Source

pub fn commits_from( &self, offset: TxOffset, ) -> impl Iterator<Item = Result<Commit, Traversal>>

Obtain an iterator over the Commits in the underlying log.

Source

pub fn existing_segment_offsets(&self) -> Result<Vec<TxOffset>>

Get a list of segment offsets, sorted in ascending order.

Source

pub fn compress_segments(&self, offsets: &[TxOffset]) -> Result<()>

Compress the segments at the offsets provided, marking them as immutable.

Source

pub async fn close(self) -> Result<Option<TxOffset>>

Apply all outstanding transactions to the Commitlog and flush it to disk.

Returns the durable TxOffset, if any.

Source

pub fn size_on_disk(&self) -> Result<u64>

Get the size on disk of the underlying Commitlog.

Trait Implementations§

Source§

impl<T: Send + Sync + 'static> Durability for Local<T>

Source§

type TxData = Txdata<T>

The payload representing a single transaction.
Source§

fn append_tx(&self, tx: Self::TxData)

Submit the transaction payload to be made durable. Read more
Source§

fn durable_tx_offset(&self) -> Option<TxOffset>

The TxOffset considered durable. Read more
Source§

impl<T: Encode + 'static> History for Local<T>

Source§

type TxData = Txdata<T>

Source§

fn fold_transactions_from<D>( &self, offset: TxOffset, decoder: D, ) -> Result<(), D::Error>
where D: Decoder, D::Error: From<Traversal>,

Traverse the history of transactions from offset and “fold” it into the provided Decoder.
Source§

fn transactions_from<'a, D>( &self, offset: TxOffset, decoder: &'a D, ) -> impl Iterator<Item = Result<Transaction<Self::TxData>, D::Error>>
where D: Decoder<Record = Self::TxData>, D::Error: From<Traversal>, Self::TxData: 'a,

Obtain an iterator over the history of transactions, starting from offset.
Source§

fn tx_range_hint(&self) -> (TxOffset, Option<TxOffset>)

Get the maximum transaction offset contained in this history. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Local<T>

§

impl<T> RefUnwindSafe for Local<T>

§

impl<T> Send for Local<T>
where T: Sync + Send,

§

impl<T> Sync for Local<T>
where T: Sync + Send,

§

impl<T> Unpin for Local<T>

§

impl<T> UnwindSafe for Local<T>

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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 = Infallible

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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