Show / Hide Table of Contents

Interface IAuditTrail<TEntry>

Represents audit trail responsible for maintaining log entries.

Inherited Members
IAuditTrail.IsLogEntryLengthAlwaysPresented
IAuditTrail.LastCommittedEntryIndex
IAuditTrail.LastEntryIndex
IAuditTrail.WaitForApplyAsync(long, CancellationToken)
IAuditTrail.WaitForApplyAsync(CancellationToken)
IAuditTrail.CommitAsync(long, CancellationToken)
IAuditTrail.InitializeAsync(CancellationToken)
IAuditTrail.ReadAsync<TResult>(ILogEntryConsumer<ILogEntry, TResult>, long, long, CancellationToken)
Namespace: DotNext.IO.Log
Assembly: DotNext.IO.dll
Syntax
public interface IAuditTrail<TEntry> : IAuditTrail where TEntry : class, ILogEntry
Type Parameters
Name Description
TEntry

The interface type of the log entry maintained by the audit trail.

Methods

| Edit this page View Source

AppendAndCommitAsync<TEntryImpl>(ILogEntryProducer<TEntryImpl>, long, bool, long, CancellationToken)

Adds uncommitted log entries and commits previously added log entries as an atomic operation.

Declaration
ValueTask<long> AppendAndCommitAsync<TEntryImpl>(ILogEntryProducer<TEntryImpl> entries, long startIndex, bool skipCommitted, long commitIndex, CancellationToken token = default) where TEntryImpl : TEntry
Parameters
Type Name Description
ILogEntryProducer<TEntryImpl> entries

Stateful object that is responsible for supplying log entries.

long startIndex

The index from which all previous log entries should be dropped and replaced with new entries.

bool skipCommitted

true to skip committed entries from entries instead of throwing exception.

long commitIndex

The index of the last entry to commit, inclusively.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask<long>

The actual number of committed entries.

Type Parameters
Name Description
TEntryImpl

The actual type of the log entry returned by the supplier.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

InvalidOperationException

startIndex is less than the index of the last committed entry and skipCommitted is false; or the collection of entries contains the snapshot entry.

| Edit this page View Source

AppendAsync<TEntryImpl>(ILogEntryProducer<TEntryImpl>, long, bool, CancellationToken)

Adds uncommitted log entries into this log.

Declaration
ValueTask AppendAsync<TEntryImpl>(ILogEntryProducer<TEntryImpl> entries, long startIndex, bool skipCommitted = false, CancellationToken token = default) where TEntryImpl : TEntry
Parameters
Type Name Description
ILogEntryProducer<TEntryImpl> entries

Stateful object that is responsible for supplying log entries.

long startIndex

The index from which all previous log entries should be dropped and replaced with new entries.

bool skipCommitted

true to skip committed entries from entries instead of throwing exception.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask

The task representing asynchronous state of the method.

Type Parameters
Name Description
TEntryImpl

The actual type of the log entry returned by the supplier.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

InvalidOperationException

startIndex is less than the index of the last committed entry and skipCommitted is false; or the collection of entries contains the snapshot entry.

| Edit this page View Source

AppendAsync<TEntryImpl>(TEntryImpl, long, CancellationToken)

Adds uncommitted log entry to the end of this log.

Declaration
ValueTask AppendAsync<TEntryImpl>(TEntryImpl entry, long startIndex, CancellationToken token = default) where TEntryImpl : TEntry
Parameters
Type Name Description
TEntryImpl entry

The uncommitted log entry to be added into this audit trail.

long startIndex

The index from which all previous log entries should be dropped and replaced with the new entry.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask

The task representing asynchronous state of the method.

Type Parameters
Name Description
TEntryImpl

The actual type of the supplied log entry.

Remarks

This is the only method that can be used for snapshot installation. The behavior of the method depends on the IsSnapshot property. If log entry is a snapshot, then the method erases all committed log entries prior to startIndex. If it is not, the method behaves in the same way as AppendAsync<TEntryImpl>(ILogEntryProducer<TEntryImpl>, long, bool, CancellationToken).

Exceptions
Type Condition
InvalidOperationException

startIndex is less than the index of the last committed entry and entry is not a snapshot.

OperationCanceledException

The operation has been canceled.

| Edit this page View Source

AppendAsync<TEntryImpl>(TEntryImpl, CancellationToken)

Adds uncommitted log entry to the end of this log.

Declaration
ValueTask<long> AppendAsync<TEntryImpl>(TEntryImpl entry, CancellationToken token = default) where TEntryImpl : TEntry
Parameters
Type Name Description
TEntryImpl entry

The entry to add.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask<long>

The index of the added entry.

Type Parameters
Name Description
TEntryImpl

The actual type of the supplied log entry.

Remarks

This method cannot be used to append a snapshot.

Exceptions
Type Condition
InvalidOperationException

entry is the snapshot entry.

OperationCanceledException

The operation has been canceled.

| Edit this page View Source

ReadAsync<TResult>(ILogEntryConsumer<TEntry, TResult>, long, long, CancellationToken)

Gets log entries in the specified range.

Declaration
ValueTask<TResult> ReadAsync<TResult>(ILogEntryConsumer<TEntry, TResult> reader, long startIndex, long endIndex, CancellationToken token = default)
Parameters
Type Name Description
ILogEntryConsumer<TEntry, TResult> reader

The reader of the log entries.

long startIndex

The index of the first requested log entry, inclusively.

long endIndex

The index of the last requested log entry, inclusively.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask<TResult>

The collection of log entries.

Type Parameters
Name Description
TResult

The type of the result.

Remarks

This method may return fewer entries than endIndex - startIndex + 1. It may happen if the requested entries are committed and squashed into the single entry called snapshot. In this case the first entry in the collection is a snapshot entry. Additionally, the caller must call Dispose() to release resources associated with the audit trail segment with entries.

Exceptions
Type Condition
ArgumentOutOfRangeException

startIndex or endIndex is negative.

IndexOutOfRangeException

endIndex is greater than the index of the last added entry.

OperationCanceledException

The operation has been canceled.

See Also
IsSnapshot

Extension Methods

BasicExtensions.As<T>(T)
BasicExtensions.GetUserData<T>(T)
BasicExtensions.IsBetween<T, TLowerBound, TUpperBound>(T, TLowerBound, TUpperBound)
BasicExtensions.IsOneOf<T>(T, ReadOnlySpan<T>)
ExpressionBuilder.Const<T>(T)
AsyncLockAcquisition.AcquireLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireLockAsync<T>(T, TimeSpan, CancellationToken)
AsyncLockAcquisition.AcquireReadLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireReadLockAsync<T>(T, TimeSpan, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, bool, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, bool, TimeSpan, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, TimeSpan, CancellationToken)
LockAcquisition.AcquireReadLock<T>(T)
LockAcquisition.AcquireReadLock<T>(T, TimeSpan)
LockAcquisition.AcquireUpgradeableReadLock<T>(T)
LockAcquisition.AcquireUpgradeableReadLock<T>(T, TimeSpan)
LockAcquisition.AcquireWriteLock<T>(T)
LockAcquisition.AcquireWriteLock<T>(T, TimeSpan)
  • Edit this page
  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾