pub trait TransactionLog:
Send
+ Sync
+ Debug {
// Required methods
fn append<'life0, 'async_trait>(
&'life0 self,
entry: LogEntry,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn read_after<'life0, 'async_trait>(
&'life0 self,
after: HlcTimestamp,
limit: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<LogEntry>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn sweep<'life0, 'async_trait>(
&'life0 self,
policy: RetentionPolicy,
) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided method
fn append_batch<'life0, 'async_trait>(
&'life0 self,
entries: Vec<LogEntry>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
}Expand description
Per-deployment append-only log of every committed write.
One instance per deployment process; lives for the deployment’s lifetime. Entries are HLC-ordered and survive process restart (durability is the foundational contract — replication’s catch- up window relies on it).
§Contract
appendis the durability sink. Returns only after the entry has been fsynced (or the implementation’s chosen durability point); subsequentread_aftercalls on the same instance must see the new entry.read_afterreturns entries strictly greater than the given HLC, in ascending HLC order, up tolimit. Used by replication for streaming tail-reads and catch-up on peer reconnection.sweepremoves entries that exceed the retention bounds. Returns the count of removed entries. Sweep is the only operation that DELETES from the log — append is the only operation that ADDS.
§Implementations
The canonical implementation is
yeti_store::transaction_log::KvTransactionLog, backed by a
dedicated KvBackend opened at
{root_directory}/logs/transactions/{deployment_hash}/. Tests use
the in-memory MemoryBackend
under the same wrapper.
Required Methods§
Sourcefn append<'life0, 'async_trait>(
&'life0 self,
entry: LogEntry,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn append<'life0, 'async_trait>(
&'life0 self,
entry: LogEntry,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Append a new entry. The entry’s hlc is assigned by the
caller (typically from a HybridLogicalClock::now
call at commit time). The log persists the entry verbatim.
§Errors
crate::error::YetiError::Internalif encoding fails.- Whatever the underlying storage backend returns from a write.
Sourcefn read_after<'life0, 'async_trait>(
&'life0 self,
after: HlcTimestamp,
limit: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<LogEntry>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn read_after<'life0, 'async_trait>(
&'life0 self,
after: HlcTimestamp,
limit: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<LogEntry>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Read up to limit entries with hlc > after, in ascending
HLC order. after = HlcTimestamp::ZERO reads from the
beginning of the log.
§Errors
crate::error::YetiError::Internalif decoding any entry fails (indicates on-disk corruption or version skew).- Whatever the underlying storage backend returns from a scan.
Sourcefn sweep<'life0, 'async_trait>(
&'life0 self,
policy: RetentionPolicy,
) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn sweep<'life0, 'async_trait>(
&'life0 self,
policy: RetentionPolicy,
) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Remove entries that exceed the retention policy. Returns the number of entries removed.
§Errors
Whatever the underlying storage backend returns from scan + batch-delete operations.
Provided Methods§
Sourcefn append_batch<'life0, 'async_trait>(
&'life0 self,
entries: Vec<LogEntry>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn append_batch<'life0, 'async_trait>(
&'life0 self,
entries: Vec<LogEntry>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Append many entries in one call. Implementations should fuse the appends into a single batched backend write where possible — the default implementation falls back to a per-entry loop and is correct but pays one awaited backend call per entry.
Used by LoggingBackend::write_batch
so a 100-record table batch produces one storage write per
table + one batched write on the log, instead of 100 serial
awaited log puts.
§Errors
crate::error::YetiError::Internalif encoding any entry fails.- Whatever the underlying storage backend returns from a write.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".