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
impl WalWriter
Sourcepub fn create(
vfs: &dyn Vfs,
path: &Path,
first_seq: LogSeq,
policy: DurabilityPolicy,
) -> Result<Self, WalWriteError>
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.
Sourcepub fn create_with_max_group_bytes(
vfs: &dyn Vfs,
path: &Path,
first_seq: LogSeq,
policy: DurabilityPolicy,
max_group_bytes: usize,
) -> Result<Self, WalWriteError>
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.
Sourcepub fn commit(&self, op: u16, payload: &[u8]) -> Result<LogSeq, WalWriteError>
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.
Sourcepub fn commit_durable(
&self,
op: u16,
payload: &[u8],
) -> Result<LogSeq, WalWriteError>
pub fn commit_durable( &self, op: u16, payload: &[u8], ) -> Result<LogSeq, WalWriteError>
Makes one record visible, then waits until its tier-specific flush returns.
Sourcepub fn commit_many(
&self,
records: &[(u16, &[u8])],
) -> Result<Range<LogSeq>, WalWriteError>
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.
Sourcepub fn commit_many_durable(
&self,
records: &[(u16, &[u8])],
) -> Result<Range<LogSeq>, WalWriteError>
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.
Sourcepub fn flush(&self) -> Result<(), WalWriteError>
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.
Sourcepub fn visible_records(
&self,
first_seq: LogSeq,
limit: usize,
) -> Result<Vec<VisibleRecord>, WalWriteError>
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.
Sourcepub fn retire_visible_through(
&self,
absorbed_through: LogSeq,
) -> Result<WalRetirement, WalRetireError>
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.
Sourcepub fn stats(&self) -> Result<WalWriterStats, WalWriteError>
pub fn stats(&self) -> Result<WalWriterStats, WalWriteError>
Returns deterministic progress and completed-group statistics.