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>
impl<C: Crdt> DurableReplica<C>
Sourcepub fn torn_tail(&self) -> Option<TornTail>
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.
pub fn state(&self) -> &C
pub fn log(&self) -> &EventLog<C::Delta>
pub fn allocation_bytes(&self) -> Vec<u8> ⓘ
pub fn ticket(&self) -> WriteTicket
pub fn renew(&mut self, ticket: WriteTicket) -> Result<WriteTicket, LocalError>
pub fn receive( &mut self, ticket: WriteTicket, record: Record<C::Delta>, ) -> Result<Admission, LocalError>
pub fn append( &mut self, ticket: WriteTicket, delta: C::Delta, ) -> Result<Record<C::Delta>, LocalError>
Sourcepub fn append_batch(
&mut self,
ticket: WriteTicket,
deltas: impl IntoIterator<Item = C::Delta>,
) -> Result<Vec<Record<C::Delta>>, LocalError>where
C: Clone,
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>
impl DurableReplica<GCounter>
Sourcepub fn restart_counter(
root: &Path,
config: WriterConfig,
) -> Result<Self, LocalError>
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.
Sourcepub fn restart_counter_with_limits(
root: &Path,
config: WriterConfig,
limits: DecodeLimits,
) -> Result<Self, LocalError>
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.
Sourcepub fn restart_counter_from_store(
root: &Path,
writer: u64,
) -> Result<Self, LocalError>
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.
Sourcepub fn restart_counter_from_store_with_limits(
root: &Path,
writer: u64,
limits: DecodeLimits,
) -> Result<Self, LocalError>
pub fn restart_counter_from_store_with_limits( root: &Path, writer: u64, limits: DecodeLimits, ) -> Result<Self, LocalError>
restart_counter_from_store with the
restart budget of restart_counter_with_limits.
Sourcepub fn migrate_counter_to_append_log(
root: &Path,
config: WriterConfig,
) -> Result<Self, LocalError>
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.
pub fn counter(root: &Path, config: WriterConfig) -> Result<Self, LocalError>
pub fn bump( &mut self, ticket: WriteTicket, tally: u64, ) -> Result<Record<GCounterDelta>, LocalError>
Sourcepub fn bump_batch(
&mut self,
ticket: WriteTicket,
tallies: impl IntoIterator<Item = u64>,
) -> Result<Vec<Record<GCounterDelta>>, LocalError>
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>>
impl DurableReplica<OrSet<String, u64>>
Sourcepub fn restart_utf8_set(
root: &Path,
config: WriterConfig,
) -> Result<Self, LocalError>
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.
Sourcepub fn restart_utf8_set_with_limits(
root: &Path,
config: WriterConfig,
limits: DecodeLimits,
) -> Result<Self, LocalError>
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.
Sourcepub fn restart_utf8_set_with_max_collection_elements(
root: &Path,
config: WriterConfig,
max_elements: usize,
) -> Result<Self, LocalError>
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.
pub fn utf8_set(root: &Path, config: WriterConfig) -> Result<Self, LocalError>
Sourcepub fn migrate_utf8_set_to_append_log(
root: &Path,
config: WriterConfig,
) -> Result<Self, LocalError>
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.
pub fn add( &mut self, ticket: WriteTicket, element: String, ) -> Result<Record<OrSetDelta<String, u64>>, LocalError>
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>
impl<C> Send for DurableReplica<C>
impl<C> Sync for DurableReplica<C>
impl<C> Unpin for DurableReplica<C>
impl<C> UnsafeUnpin for DurableReplica<C>where
C: UnsafeUnpin,
impl<C> UnwindSafe for DurableReplica<C>
Blanket Implementations§
Source§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
Source§fn type_id(&self) -> TypeId
fn type_id(&self) -> TypeId
TypeId of self. Read moreSource§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
Source§fn borrow(&self) -> &T
fn borrow(&self) -> &T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T, U> Into<U> for Twhere
U: From<T>,
impl<T, U> Into<U> for Twhere
U: From<T>,
Source§fn into(self) -> U
fn into(self) -> U
Calls U::from(self).
That is, this conversion is whatever the implementation of
From<T> for U chooses to do.