Class FileTransitionLog
- Namespace
- Foundation.Data.Doublets.Cli
- Assembly
- Foundation.Data.Doublets.Cli.dll
Append-only, line-oriented transitions log backed by a single file:
rust/src/transactions/log.rs FileTransitionLog.
public sealed class FileTransitionLog : ITransitionLogStore, IDisposable
- Inheritance
-
FileTransitionLog
- Implements
- Inherited Members
Remarks
Appending costs one write and one flush to stable storage regardless of
how many entries the log already holds. Retention policies compact it
through CompactLogEntries(IReadOnlyList<string>), which writes the retained entries
to <path>.compact, syncs it and renames it over the log, so
the journal on disk stays bounded (issue #195).
An interrupted append can leave a partial final line. Opening the log, or reading, appending or flushing after a writer I/O error, repairs that suffix before proceeding; trailing lines holding NUL, which power loss can leave, are dropped too. A failed repair is retried on the next operation.
Properties
Path
Path of the backing file.
public string Path { get; }
Property Value
SupportsCompaction
Whether CompactLogEntries(IReadOnlyList<string>) can rewrite the durable journal. Retention uses it to bound the journal on disk; logs without it keep every entry, as before.
public bool SupportsCompaction { get; }
Property Value
SupportsDurableFlush
Whether FlushLog() requests persistent storage. This describes the adapter, not the reliability of its hardware.
public bool SupportsDurableFlush { get; }
Property Value
SyncOnAppend
Whether every append is flushed to stable storage. Enabled by default.
public bool SyncOnAppend { get; set; }
Property Value
Methods
AppendLogEntry(string)
Appends one entry. Entries never contain line breaks.
public void AppendLogEntry(string entry)
Parameters
entrystring
CompactLogEntries(IReadOnlyList<string>)
Atomically and durably replaces every entry with
entries, the retained journal. After a crash the log
holds either the old or the new journal, never a mixture. Called only
between transactions and only when SupportsCompaction is
true.
public void CompactLogEntries(IReadOnlyList<string> entries)
Parameters
entriesIReadOnlyList<string>
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
FlushLog()
Makes every appended entry durable.
public void FlushLog()
Open(string)
Opens (creating if needed) the log at path,
discarding a trailing entry left half-written by a crash.
public static FileTransitionLog Open(string path)
Parameters
pathstring
Returns
ReadLogEntries()
Reads every entry back, oldest first.
public IReadOnlyList<string> ReadLogEntries()