Expand description
Optional transactions layer for the Rust link-cli.
Mirrors the C# TransactionsDecorator in
csharp/Foundation.Data.Doublets.Cli.Library/TransactionsDecorator.cs.
The decorator records every create / update / delete as a
reversible GenericTransition in a sidecar log. It supports
explicit transactions, sync commits, three retention policies, and
crash recovery (R1-R7, R10).
Optional — when not opted in, the bare
NamedTypesDecorator behaves
identically (R8, R9, R17).
§Reuse outside the CLI
GenericTransactionsDecorator is generic over three things:
T— the doublets address type (u32,u64,usize, …);S— the wrapped store, anyLinksStorage<T>implementation, includingDoubletsStorageover a file-mapped or caller-owneddoublets::unit::Store;L— the transitions log, anyTransitionLogStore.
TransactionsDecorator is the u32 + NamedTypesDecorator
specialisation used by clink itself.
use link_cli::transactions::{
CommitMode, FileTransitionLog, GenericTransactionsDecorator, LogRetentionPolicy,
};
use link_cli::DoubletsStorage;
let store = DoubletsStorage::<usize, _>::open_exclusive("db.links")?;
let log = FileTransitionLog::open("db.transitions.log")?;
let mut tx = GenericTransactionsDecorator::new(
store,
log,
LogRetentionPolicy::default(),
CommitMode::default(),
false,
)?;
tx.begin_transaction()?;
let link = tx.create(0, 0)?;
tx.commit()?;
tx.save()?;§Durability
Transitions are durably logged before commit is acknowledged. Commit then flushes the wrapped data before persisting its applied markers. Recovery replays committed-but-unapplied transitions and undoes logged uncommitted changes, reporting replay and flush failures.
The default RowUndoPolicy::Observed mutates the store before recording
callbacks and leaves a crash window for unlogged changes. Select
RowUndoPolicy::WriteAheadImage to flush a complete logical undo image
before the first effect and reconcile complete history after each write.
It requires exclusive ownership and an adapter supporting logical replay;
it does not repair torn physical storage. The optional
crate::engine::Engine stages private changes until durable publication.
Structs§
- File
Transition Log - Append-only, line-oriented transitions log backed by a single file.
- Generic
Doublet Link - A single doublet link state captured by a transition (mirror of the
C#
Platform.Data.Doublets.Link<TLinkAddress>). - Generic
Transactions Decorator - The transactions decorator wraps any
LinksStorageand records every write as a reversibleGenericTransitioninlog_store. - Generic
Transition - Reversible write captured by the transactions layer. Holds both
beforeandafterlink states so the operation can be undone or replayed. - Journal
Record - A row transition plus optional name state, or an independent name write. Use this complete value for recovery, archives and version movement.
- Name
Change - Logical name state for one address, including names of absent rows.
- Transaction
Handle - Snapshot of an open transaction (returned by
GenericTransactionsDecorator::begin_transaction).
Enums§
- Commit
Mode - Sync flushes data-store side-effects before
commitreturns. - LogRetention
Policy - Retention policy for the transitions log.
- RowUndo
Policy - Undo source for the ordinary, immediately mutating storage adapter.
- Transition
Kind - The kind of write operation recorded by a
Transition.
Traits§
- Replaceable
Transition LogStore - Optional replacement of a complete ordered journal under the same exclusive owner. Success publishes all records atomically and durably when advertised. An uncertain failure fences the implementation until actual reopening.
- Transition
LogStore - Append-only store of serialized transitions and recovery markers.
Functions§
- import_
links_ journal - Copies every entry of the links-backed journal at
legacyinto the text journal attarget, then removes the legacy store. Returns whether anything was imported. - is_
links_ journal - Whether
pathholds something other than a text journal: a non-empty file whose first bytes are not (a prefix of) the journal entry prefix. - make_
legacy_ transitions_ filename - Path of the links-backed journal older versions kept:
<stem>.transitions.links. - make_
transitions_ log_ filename - Conventional journal path:
<stem>.transitions.lognext todatabase. - open_
transitions_ journal - Opens the journal of
database:explicitwhen given, the conventional<stem>.transitions.logotherwise, importing a legacy links-backed journal first (see the module documentation).
Type Aliases§
- Doublet
Link - The
u32-addressed doublet used by theclinkCLI. - File
Transactions Decorator - The specialisation
clinkuses: an append-onlyFileTransitionLogjournal, whose cost per write does not grow with history (issue #195). - Transactions
Decorator - The
u32+NamedTypesDecoratorspecialisation with the original links-backed sidecar log. - Transition
- The
u32-addressed transition used by theclinkCLI.