Struct WalWriter
pub struct WalWriter { /* private fields */ }Expand description
Where the next batch goes. Pure: the I/O layer writes the bytes.
Implementations§
§impl WalWriter
impl WalWriter
pub fn resume(
group: u32,
life: u64,
segment: u64,
salt: u64,
segment_bytes: u64,
offset: u64,
next_seq: u64,
prev: u64,
) -> Self
pub fn resume( group: u32, life: u64, segment: u64, salt: u64, segment_bytes: u64, offset: u64, next_seq: u64, prev: u64, ) -> Self
Continues the chain after recovery: the next batch is next_seq, its
prev is prev, and it goes at offset of segment, right after
the accepted prefix (so the chain has one possible next position).
Bytes a torn write left there are overwritten; any beyond the new
batch can never join the chain.
pub fn next_seq(&self) -> u64
pub fn segment(&self) -> u64
pub fn offset(&self) -> u64
pub fn roll(
&mut self,
segment: u64,
salt: u64,
segment_bytes: u64,
now_ms: u64,
) -> WalHeader
pub fn roll( &mut self, segment: u64, salt: u64, segment_bytes: u64, now_ms: u64, ) -> WalHeader
Moves to a new segment with no batch to carry there: the header to write at its start, durably, before anything else uses it. The chain continues there exactly as after a roll (the header names the next batch and the checksum the chain ended with), so the segments before it can be retired once nothing needs their batches.
pub fn place(
&mut self,
sections: &[SectionRef<'_>],
acked: u64,
pipelined: bool,
now_ms: u64,
next_segment: impl FnOnce() -> (u64, u64, u64),
) -> Placed
pub fn place( &mut self, sections: &[SectionRef<'_>], acked: u64, pipelined: bool, now_ms: u64, next_segment: impl FnOnce() -> (u64, u64, u64), ) -> Placed
Encodes the next batch. pipelined: another write may start before
this one completes, so the batch is padded to the end of its last
block (see batch_span) and the next one starts in a block of its
own. Without it, the next write shares this batch’s last block and
must not start before this one completed.
next_segment supplies (number, salt, size) when the batch does not
fit in the current segment.