Show / Hide Table of Contents

Interface IAuditTrail

Represents audit trail responsible for maintaining log entries.

Namespace: DotNext.IO.Log
Assembly: DotNext.IO.dll
Syntax
public interface IAuditTrail

Methods

| Improve this Doc View Source

CommitAsync(Int64, CancellationToken)

Commits log entries into the underlying storage and marks these entries as committed.

Declaration
ValueTask<long> CommitAsync(long endIndex, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Int64 endIndex

The index of the last entry to commit, inclusively; if null then commits all log entries started from the first uncommitted entry to the last existing log entry.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask<Int64>

The actual number of committed entries.

Remarks

This method should updates cached value provided by method GetLastIndex(Boolean) called with argument of value true. Additionally, it may force log compaction and squash all committed entries into single entry called snapshot.

Exceptions
Type Condition
OperationCanceledException

The operation has been cancelled.

| Improve this Doc View Source

CommitAsync(CancellationToken)

Commits log entries into the underlying storage and marks these entries as committed.

Declaration
ValueTask<long> CommitAsync(CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask<Int64>

The actual number of committed entries.

Remarks

This method should updates cached value provided by method GetLastIndex(Boolean) called with argument of value true. Additionally, it may force log compaction and squash all committed entries into single entry called snapshot.

Exceptions
Type Condition
OperationCanceledException

The operation has been cancelled.

| Improve this Doc View Source

CreateBackupAsync(Stream, CancellationToken)

Creates backup of this audit trail.

Declaration
virtual Task CreateBackupAsync(Stream output, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Stream output

The stream used to store backup.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
Task

A task representing state of asynchronous execution.

Exceptions
Type Condition
NotSupportedException

Backup is not supported by this implementation of audit trail.

OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

GetLastIndex(Boolean)

Gets index of the committed or last log entry.

Declaration
long GetLastIndex(bool committed)
Parameters
Type Name Description
Boolean committed

true to get the index of highest log entry known to be committed; false to get the index of the last log entry.

Returns
Type Description
Int64

The index of the log entry.

Remarks

This method is synchronous because returning value should be cached and updated in memory by implementing class.

| Improve this Doc View Source

InitializeAsync(CancellationToken)

Initializes audit trail.

Declaration
Task InitializeAsync(CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
Task

A task representing state of asynchronous execution.

Remarks

This action may perform cache initialization or other internal data structures. It can save the performance of the first modification performed to this log.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

ReadAsync<TReader, TResult>(TReader, Int64, Int64, CancellationToken)

Gets log entries in the specified range.

Declaration
ValueTask<TResult> ReadAsync<TReader, TResult>(TReader reader, long startIndex, long endIndex, CancellationToken token = default(CancellationToken))

    where TReader : ILogEntryConsumer<ILogEntry, TResult>
Parameters
Type Name Description
TReader reader

The reader of the log entries.

Int64 startIndex

The index of the first requested log entry, inclusively.

Int64 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
TReader

The type of the reader.

TResult

The type of the result.

Remarks

This method may return less entries than endIndex - startIndex + 1. It may happen if the requested entries are committed entries 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.

See Also
IsSnapshot
| Improve this Doc View Source

ReadAsync<TReader, TResult>(TReader, Int64, CancellationToken)

Gets log entries starting from the specified index to the last log entry.

Declaration
ValueTask<TResult> ReadAsync<TReader, TResult>(TReader reader, long startIndex, CancellationToken token = default(CancellationToken))

    where TReader : ILogEntryConsumer<ILogEntry, TResult>
Parameters
Type Name Description
TReader reader

The reader of the log entries.

Int64 startIndex

The index of the first 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
TReader

The type of the reader.

TResult

The type of the result.

Exceptions
Type Condition
ArgumentOutOfRangeException

startIndex is negative.

See Also
IsSnapshot
| Improve this Doc View Source

WaitForCommitAsync(Int64, TimeSpan, CancellationToken)

Waits for the commit.

Declaration
virtual Task<bool> WaitForCommitAsync(long index, TimeSpan timeout, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
Int64 index

The index of the log record to be committed.

TimeSpan timeout

The timeout used to wait for the commit.

CancellationToken token

The token that can be used to cancel waiting.

Returns
Type Description
Task<Boolean>

true if log entry with the specified index is committed; otherwise, false.

Exceptions
Type Condition
ArgumentOutOfRangeException

index is less than 1.

OperationCanceledException

The operation has been cancelled.

TimeoutException

Timeout occurred.

| Improve this Doc View Source

WaitForCommitAsync(TimeSpan, CancellationToken)

Waits for the commit.

Declaration
Task<bool> WaitForCommitAsync(TimeSpan timeout, CancellationToken token)
Parameters
Type Name Description
TimeSpan timeout

The timeout used to wait for the commit.

CancellationToken token

The token that can be used to cancel waiting.

Returns
Type Description
Task<Boolean>

true if log entry is committed; otherwise, false.

Exceptions
Type Condition
OperationCanceledException

The operation has been cancelled.

Extension Methods

AsyncLockAcquisition.AcquireLockAsync<T>(T, TimeSpan)
AsyncLockAcquisition.AcquireLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireReadLockAsync<T>(T, TimeSpan)
AsyncLockAcquisition.AcquireReadLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, TimeSpan)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireUpgradeableReadLockAsync<T>(T, TimeSpan)
AsyncLockAcquisition.AcquireUpgradeableReadLockAsync<T>(T, CancellationToken)
ObjectExtensions.GetUserData<T>(T)
ObjectExtensions.IsOneOf<T>(T, IEnumerable<T>)
ObjectExtensions.IsOneOf<T>(T, T[])
ObjectExtensions.Decompose<T, TResult1, TResult2>(T, Func<T, TResult1>, Func<T, TResult2>, out TResult1, out TResult2)
ObjectExtensions.Decompose<T, TResult1, TResult2>(T, ValueFunc<T, TResult1>, ValueFunc<T, TResult2>, out TResult1, out TResult2)
ObjectExtensions.Decompose<T, TResult1, TResult2>(T, Func<T, TResult1>, Func<T, TResult2>)
ObjectExtensions.Decompose<T, TResult1, TResult2>(T, ValueFunc<T, TResult1>, ValueFunc<T, TResult2>)
ObjectExtensions.As<T>(T)
LockAcquisition.AcquireReadLock<T>(T)
LockAcquisition.AcquireReadLock<T>(T, TimeSpan)
LockAcquisition.AcquireWriteLock<T>(T)
LockAcquisition.AcquireWriteLock<T>(T, TimeSpan)
LockAcquisition.AcquireUpgradeableReadLock<T>(T)
LockAcquisition.AcquireUpgradeableReadLock<T>(T, TimeSpan)
ExpressionBuilder.Const<T>(T)
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX