Skip to main content

WalWriter

Struct WalWriter 

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

Single-store WAL writer using caller threads as leader and followers.

There is no timer and no background flusher. An idle arrival immediately becomes leader. Arrivals observed while its barrier is in flight form the next byte-bounded group, which that leader issues immediately afterward.

Implementations§

Source§

impl WalWriter

Source

pub fn create( vfs: &dyn Vfs, path: &Path, first_seq: LogSeq, policy: DurabilityPolicy, ) -> Result<Self, WalWriteError>

Creates a writer over a new or empty WAL path.

A resolved full-sync data-file requirement uses the 16 MiB durable group bound. Barrier and skip requirements retain the 1 MiB default.

Source

pub fn create_with_max_group_bytes( vfs: &dyn Vfs, path: &Path, first_seq: LogSeq, policy: DurabilityPolicy, max_group_bytes: usize, ) -> Result<Self, WalWriteError>

Creates a writer with an explicit encoded-byte group bound.

Source

pub fn commit(&self, op: u16, payload: &[u8]) -> Result<LogSeq, WalWriteError>

Makes one record visible and returns without waiting when another caller already owns the in-flight barrier.

Source

pub fn commit_durable( &self, op: u16, payload: &[u8], ) -> Result<LogSeq, WalWriteError>

Makes one record visible, then waits until its tier-specific flush returns.

Source

pub fn commit_many( &self, records: &[(u16, &[u8])], ) -> Result<Range<LogSeq>, WalWriteError>

Makes every record in one caller batch visible in input order.

Returns after every record is visible. As with Self::commit, an idle caller that becomes leader runs the pending flushes inline before returning. An empty batch returns the empty range at the next sequence and performs no I/O.

The returned half-open range contains exactly the assigned sequences. If staging fails, the batch consumes no sequence and publishes no visibility. After staging succeeds, an append or flush failure follows the existing poisoned-writer path: the staged records remain visible, this call returns WalWriteError::Failed, and the writer rejects subsequent work.

Source

pub fn commit_many_durable( &self, records: &[(u16, &[u8])], ) -> Result<Range<LogSeq>, WalWriteError>

Makes every record in one caller batch visible in input order, then waits until the tier-specific flush covering the final record returns.

An empty batch returns the empty range at the next sequence and performs no I/O.

The returned half-open range contains exactly the assigned sequences. If staging fails, the batch consumes no sequence and publishes no visibility. After staging succeeds, an append or flush failure follows the existing poisoned-writer path: the staged records remain visible, this call returns WalWriteError::Failed, and the writer rejects subsequent work.

Source

pub fn flush(&self) -> Result<(), WalWriteError>

Waits until every record visible when this call observes the writer has flushed.

No record is appended solely to force progress. If pending records have no current leader, this caller assumes leadership and drains them.

Source

pub fn visible_records( &self, first_seq: LogSeq, limit: usize, ) -> Result<Vec<VisibleRecord>, WalWriteError>

Returns at most limit retained records at or after first_seq.

Clones share the encoded WAL allocations. The explicit bound prevents test-support callers from copying metadata for the writer’s history.

Source

pub fn retire_visible_through( &self, absorbed_through: LogSeq, ) -> Result<WalRetirement, WalRetireError>

Releases retained visibility records through an absorbed durable sequence.

The ingest owner calls this only after incorporating the records into its own in-memory state. Requests beyond the tier-specific durable end fail explicitly and never clamp.

Source

pub fn stats(&self) -> Result<WalWriterStats, WalWriteError>

Returns deterministic progress and completed-group statistics.

Trait Implementations§

Source§

impl DurableLog for WalWriter

Source§

fn durable_end(&self) -> u64

Returns the largest sequence known durable.

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