pub struct FileLog { /* private fields */ }Expand description
Filesystem append log. Each append is flushed and fsynced before returning.
The file descriptor remains open for the lifetime of the log. An in-memory
(t, byte offset, frame length) index is built during recovery, extended
on append, and used to read only the frames selected by a range scan.
A crash mid-append leaves a torn, never-acked record at the tail; open
truncates it away so replay stops at the durability point of the last
acked transaction and later appends extend a clean tail.
Implementations§
Source§impl FileLog
impl FileLog
Sourcepub fn open(path: impl AsRef<Path>) -> Result<Self, LogError>
pub fn open(path: impl AsRef<Path>) -> Result<Self, LogError>
Opens or creates a log file, dropping any torn tail left by a crash.
§Errors
Returns an error if the file cannot be created or a fully written record is corrupt.
Sourcepub fn open_sealed(
path: impl AsRef<Path>,
cipher: Arc<LogCipher>,
) -> Result<Self, LogError>
pub fn open_sealed( path: impl AsRef<Path>, cipher: Arc<LogCipher>, ) -> Result<Self, LogError>
Opens or creates a log whose record payloads are sealed under cipher.
A single-file log has no lease versions, so its records bind lease
version 0 — the same number VersionedLog gives a pre-HA {name}.log.
§Errors
Returns an error if the file cannot be created, a fully written record is corrupt, or a record cannot be authenticated.
Trait Implementations§
Source§impl TransactionLog for FileLog
impl TransactionLog for FileLog
Source§fn append(&self, record: &TxRecord) -> Result<(), LogError>
fn append(&self, record: &TxRecord) -> Result<(), LogError>
Source§fn tx_range(
&self,
start: u64,
end: Option<u64>,
) -> Result<Vec<TxRecord>, LogError>
fn tx_range( &self, start: u64, end: Option<u64>, ) -> Result<Vec<TxRecord>, LogError>
[start, end). Read moreSource§fn append_async<'life0, 'life1, 'async_trait>(
&'life0 self,
record: &'life1 TxRecord,
) -> Pin<Box<dyn Future<Output = Result<(), LogError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn append_async<'life0, 'life1, 'async_trait>(
&'life0 self,
record: &'life1 TxRecord,
) -> Pin<Box<dyn Future<Output = Result<(), LogError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Self::append by default;
storage-backed logs override this method and await their backend. Read moreSource§fn append_batch_async<'life0, 'life1, 'async_trait>(
&'life0 self,
records: &'life1 [TxRecord],
) -> Pin<Box<dyn Future<Output = Result<(), LogError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn append_batch_async<'life0, 'life1, 'async_trait>(
&'life0 self,
records: &'life1 [TxRecord],
) -> Pin<Box<dyn Future<Output = Result<(), LogError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fsync, one
object, one database transaction), so group commit amortizes the
per-append cost across the batch. records must be contiguous in t
starting at the log’s next expected t; an empty slice is a no-op. The
default appends them one at a time; batching backends override this. Read more