Trait mz_persist::location::Log
source · [−]pub trait Log {
fn write_sync(&mut self, buf: Vec<u8>) -> Result<SeqNo, Error>;
fn snapshot<F>(&self, logic: F) -> Result<Range<SeqNo>, Error>
where
F: FnMut(SeqNo, &[u8]) -> Result<(), Error>;
fn truncate(&mut self, upper: SeqNo) -> Result<(), Error>;
fn close(&mut self) -> Result<bool, Error>;
}
Expand description
An abstraction over an append-only bytes log.
Each written entry is assigned a unique, incrementing SeqNo, which can be later used when draining data back out of the log.
- Invariant: Implementations are responsible for ensuring that they are exclusive writers to this location.
Required methods
Synchronously appends an entry.
TODO: Figure out our async story so we can batch up multiple of these into one disk flush.
Returns a consistent snapshot of all written but not yet truncated entries.
- Invariant: all returned entries must have a sequence number within the declared [lower, upper) range of sequence numbers.
Removes all entries with a SeqNo strictly less than the given upper bound.