Skip to main content

DurableReplica

Struct DurableReplica 

Source
pub struct DurableReplica<C: Crdt> { /* private fields */ }
Expand description

Additive durable API for Linux local filesystems. Fresh constructors create a missing root; the root must then remain in place. All writers use the same fixed root and configuration. Fresh stores keep an append-only writer-<id>.journal: each Accepted/Ok(record) follows appending that one record and syncing the file. Stores written before the append log keep writer-<id>.transaction, which restart still opens and each commit still replaces whole, with file + directory sync, until an explicit migrate_*_to_append_log call; restart never migrates. Any persistence error permanently disables this instance’s writes, retaining its fence until drop. Use the explicit restart constructors for existing stores; fresh constructors never reset a store.

Implementations§

Source§

impl<C: Crdt> DurableReplica<C>
where C::Delta: OwnedDelta + Clone + PartialEq + WireEncode + WireSchema,

Source

pub fn torn_tail(&self) -> Option<TornTail>

The torn tail this instance’s restart discarded from an append-log store, if any. None for a fresh store, a transaction-format store and a journal that ended on a complete record.

Source

pub fn state(&self) -> &C

Source

pub fn log(&self) -> &EventLog<C::Delta>

Source

pub fn allocation_bytes(&self) -> Vec<u8> ⓘ

Source

pub fn ticket(&self) -> WriteTicket

Source

pub fn renew(&mut self, ticket: WriteTicket) -> Result<WriteTicket, LocalError>

Source

pub fn receive( &mut self, ticket: WriteTicket, record: Record<C::Delta>, ) -> Result<Admission, LocalError>

Source

pub fn append( &mut self, ticket: WriteTicket, delta: C::Delta, ) -> Result<Record<C::Delta>, LocalError>

Source

pub fn append_batch( &mut self, ticket: WriteTicket, deltas: impl IntoIterator<Item = C::Delta>, ) -> Result<Vec<Record<C::Delta>>, LocalError>
where C: Clone,

Commit local deltas as one durable batch. The counter records the final sequence before any journal entry is written. An interrupted batch can therefore require recovery, as an interrupted single append can.

Source§

impl DurableReplica<GCounter>

Source

pub fn restart_counter( root: &Path, config: WriterConfig, ) -> Result<Self, LocalError>

Reacquire ownership, validate the committed history and replay fresh state. Any error returns no replica and grants no write ticket.

Source

pub fn restart_counter_with_limits( root: &Path, config: WriterConfig, limits: DecodeLimits, ) -> Result<Self, LocalError>

restart_counter with a restart budget. limits.max_records refuses a history declaring more records with LocalError::RecordLimitExceeded before any record is read, leaving the store unchanged. max_collection_elements: None keeps the ordinary stored-byte collection budget rather than the 4,096 wire default.

Source

pub fn restart_counter_from_store( root: &Path, writer: u64, ) -> Result<Self, LocalError>

Reacquire the writer, read its committed writer count, then run checked replay. The root must already contain a durable counter store for this writer.

Source

pub fn restart_counter_from_store_with_limits( root: &Path, writer: u64, limits: DecodeLimits, ) -> Result<Self, LocalError>

Source

pub fn migrate_counter_to_append_log( root: &Path, config: WriterConfig, ) -> Result<Self, LocalError>

Explicitly move a counter store written before the append log (writer-<id>.transaction) to the append log (writer-<id>.journal), after the same checked replay as restart_counter, and return it ready to write. Every record is kept. Restart never migrates. If a crash leaves both files, restart refuses with RecoveryRequired and calling this again completes the move. An append-log store is restarted unchanged.

Source

pub fn counter(root: &Path, config: WriterConfig) -> Result<Self, LocalError>

Source

pub fn bump( &mut self, ticket: WriteTicket, tally: u64, ) -> Result<Record<GCounterDelta>, LocalError>

Source

pub fn bump_batch( &mut self, ticket: WriteTicket, tallies: impl IntoIterator<Item = u64>, ) -> Result<Vec<Record<GCounterDelta>>, LocalError>

Append many increasing local tallies with one counter write and one journal sync. An empty batch has no effect.

Source§

impl DurableReplica<OrSet<String, u64>>

Source

pub fn restart_utf8_set( root: &Path, config: WriterConfig, ) -> Result<Self, LocalError>

Checked ordinary restart, including tombstones and token allocation. Budgets stored collection counts from the committed transaction length.

Source

pub fn restart_utf8_set_with_limits( root: &Path, config: WriterConfig, limits: DecodeLimits, ) -> Result<Self, LocalError>

restart_utf8_set with a restart budget. limits.max_records refuses a history declaring more records with LocalError::RecordLimitExceeded before any record is read, leaving the store unchanged. max_collection_elements: None keeps the ordinary stored-byte collection budget; Some(n) matches restart_utf8_set_with_max_collection_elements.

Source

pub fn restart_utf8_set_with_max_collection_elements( root: &Path, config: WriterConfig, max_elements: usize, ) -> Result<Self, LocalError>

Restart a stored set with an explicit collection ceiling instead of the ordinary stored-byte budget.

Source

pub fn utf8_set(root: &Path, config: WriterConfig) -> Result<Self, LocalError>

Source

pub fn migrate_utf8_set_to_append_log( root: &Path, config: WriterConfig, ) -> Result<Self, LocalError>

Explicitly move a UTF-8 OR-Set store written before the append log to the append log, as migrate_counter_to_append_log does for a counter, after the same checked replay as restart_utf8_set.

Source

pub fn add( &mut self, ticket: WriteTicket, element: String, ) -> Result<Record<OrSetDelta<String, u64>>, LocalError>

Source

pub fn remove( &mut self, ticket: WriteTicket, element: &String, ) -> Result<Record<OrSetDelta<String, u64>>, LocalError>

Auto Trait Implementations§

§

impl<C> Freeze for DurableReplica<C>
where C: Freeze,

§

impl<C> RefUnwindSafe for DurableReplica<C>
where C: RefUnwindSafe, <C as Crdt>::Delta: RefUnwindSafe,

§

impl<C> Send for DurableReplica<C>
where C: Send, <C as Crdt>::Delta: Send,

§

impl<C> Sync for DurableReplica<C>
where C: Sync, <C as Crdt>::Delta: Sync,

§

impl<C> Unpin for DurableReplica<C>
where C: Unpin, <C as Crdt>::Delta: Unpin,

§

impl<C> UnsafeUnpin for DurableReplica<C>
where C: UnsafeUnpin,

§

impl<C> UnwindSafe for DurableReplica<C>
where C: UnwindSafe, <C as Crdt>::Delta: RefUnwindSafe + UnwindSafe,

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 = 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.