Class TransactionsDecorator<TLinkAddress>
- Namespace
- Foundation.Data.Doublets.Cli
- Assembly
- Foundation.Data.Doublets.Cli.dll
Decorator that records every Create/Update/Delete
as a reversible Transition<TLinkAddress> in a sidecar doublets log
store. Supports explicit transactions, sync/async commits, three log
retention policies, and crash recovery. Optional — no behavioural
change if not opted in (R8).
public class TransactionsDecorator<TLinkAddress> : LinksDecoratorBase<TLinkAddress>, ITransactionsLinks<TLinkAddress>, INamedTypesLinks<TLinkAddress>, ILinks<TLinkAddress>, ILinks<TLinkAddress, LinksConstants<TLinkAddress>>, INamedTypes<TLinkAddress>, IDisposable where TLinkAddress : IUnsignedNumber<TLinkAddress>
Type Parameters
TLinkAddress
- Inheritance
-
LinksOperatorBase<TLinkAddress>LinksDecoratorBase<TLinkAddress>TransactionsDecorator<TLinkAddress>
- Implements
-
ITransactionsLinks<TLinkAddress>INamedTypesLinks<TLinkAddress>ILinks<TLinkAddress>ILinks<TLinkAddress, LinksConstants<TLinkAddress>>INamedTypes<TLinkAddress>
- Derived
- Inherited Members
-
LinksDecoratorBase<TLinkAddress>._constantsLinksDecoratorBase<TLinkAddress>._facadeLinksDecoratorBase<TLinkAddress>.FacadeLinksDecoratorBase<TLinkAddress>.ConstantsLinksOperatorBase<TLinkAddress>._linksLinksOperatorBase<TLinkAddress>.Links
- Extension Methods
Constructors
TransactionsDecorator(INamedTypesLinks<TLinkAddress>, INamedTypesLinks<TLinkAddress>, LogRetentionPolicy?, CommitMode, bool)
public TransactionsDecorator(INamedTypesLinks<TLinkAddress> inner, INamedTypesLinks<TLinkAddress> logStore, LogRetentionPolicy? retentionPolicy = null, CommitMode commitMode = CommitMode.Sync, bool trace = false)
Parameters
innerINamedTypesLinks<TLinkAddress>logStoreINamedTypesLinks<TLinkAddress>retentionPolicyLogRetentionPolicycommitModeCommitModetracebool
Properties
AppliedSequence
public long AppliedSequence { get; }
Property Value
CommitMode
public CommitMode CommitMode { get; set; }
Property Value
LastLoggedSequence
public long LastLoggedSequence { get; }
Property Value
Log
public IReadOnlyList<Transition<TLinkAddress>> Log { get; }
Property Value
- IReadOnlyList<Transition<TLinkAddress>>
RetentionPolicy
public LogRetentionPolicy RetentionPolicy { get; set; }
Property Value
Methods
ApplyTransition(Transition<TLinkAddress>)
Apply a single transition's side-effect against the data store without writing a new log entry. Intended for use by higher-level decorators (e.g. version control) that need to drive replay/rewind without producing additional transitions.
public virtual void ApplyTransition(Transition<TLinkAddress> transition)
Parameters
transitionTransition<TLinkAddress>
BeginTransaction()
public virtual ITransaction<TLinkAddress> BeginTransaction()
Returns
- ITransaction<TLinkAddress>
BeginTransactionAsync(CancellationToken)
public virtual Task<ITransaction<TLinkAddress>> BeginTransactionAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationToken
Returns
- Task<ITransaction<TLinkAddress>>
Create(IList<TLinkAddress>?, WriteHandler<TLinkAddress>?)
Creates the restriction.
public override TLinkAddress Create(IList<TLinkAddress>? substitution, WriteHandler<TLinkAddress>? handler)
Parameters
substitutionIList<TLinkAddress>handlerWriteHandler<TLinkAddress>
Returns
- TLinkAddress
The link
Delete(IList<TLinkAddress>?, WriteHandler<TLinkAddress>?)
Deletes the restriction.
public override TLinkAddress Delete(IList<TLinkAddress>? restriction, WriteHandler<TLinkAddress>? handler)
Parameters
restrictionIList<TLinkAddress>The restriction.
handlerWriteHandler<TLinkAddress>
Returns
- TLinkAddress
Dispose()
Stops the background worker. The wrapped data store and log store are not disposed here; callers are expected to own those.
public void Dispose()
Dispose(bool)
Stops the background worker. Derived decorators that own extra
resources override this and call base.Dispose(disposing).
protected virtual void Dispose(bool disposing)
Parameters
disposingbool
GetByName(string)
public virtual TLinkAddress GetByName(string name)
Parameters
namestring
Returns
- TLinkAddress
GetName(TLinkAddress)
public virtual string? GetName(TLinkAddress link)
Parameters
linkTLinkAddress
Returns
MakeTransitionsDatabaseFilename(string)
Conventional sidecar filename for the transitions log.
public static string MakeTransitionsDatabaseFilename(string databaseFilename)
Parameters
databaseFilenamestring
Returns
Recover()
public virtual void Recover()
RemoveName(TLinkAddress)
public virtual void RemoveName(TLinkAddress link)
Parameters
linkTLinkAddress
RevertTransition(Transition<TLinkAddress>)
Revert a single transition's side-effect against the data store without writing a new log entry. Intended for use by higher-level decorators (e.g. version control) that need to drive replay/rewind without producing additional transitions.
public virtual void RevertTransition(Transition<TLinkAddress> transition)
Parameters
transitionTransition<TLinkAddress>
SetName(TLinkAddress, string)
public virtual TLinkAddress SetName(TLinkAddress link, string name)
Parameters
linkTLinkAddressnamestring
Returns
- TLinkAddress
Shutdown()
Stops the background worker. Kept as a named method for backwards compatibility; Dispose() delegates to it.
public virtual void Shutdown()
Update(IList<TLinkAddress>?, IList<TLinkAddress>?, WriteHandler<TLinkAddress>?)
Updates the restriction.
public override TLinkAddress Update(IList<TLinkAddress>? restriction, IList<TLinkAddress>? substitution, WriteHandler<TLinkAddress>? handler)
Parameters
restrictionIList<TLinkAddress>The restriction.
substitutionIList<TLinkAddress>The substitution.
handlerWriteHandler<TLinkAddress>
Returns
- TLinkAddress
The link