Interface IAuditTrail
Represents audit trail responsible for maintaining log entries.
Namespace: DotNext.IO.Log
Assembly: DotNext.IO.dll
Syntax
public interface IAuditTrail
Properties
| Edit this page View SourceIsLogEntryLengthAlwaysPresented
Gets a value indicating that the length of the log entries obtained from this audit trail is always not null.
Declaration
bool IsLogEntryLengthAlwaysPresented { get; }
Property Value
Type | Description |
---|---|
bool |
LastCommittedEntryIndex
Gets the index of the last committed log entry.
Declaration
long LastCommittedEntryIndex { get; }
Property Value
Type | Description |
---|---|
long |
LastEntryIndex
Gets the index of the last added log entry (committed or not).
Declaration
long LastEntryIndex { get; }
Property Value
Type | Description |
---|---|
long |
Methods
| Edit this page View SourceCommitAsync(long, CancellationToken)
Commits log entries into the underlying storage and marks these entries as committed.
Declaration
ValueTask<long> CommitAsync(long endIndex, CancellationToken token = default)
Parameters
Type | Name | Description |
---|---|---|
long | endIndex | 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. |
Remarks
This method should updates cached value provided by method LastCommittedEntryIndex 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. |
CommitAsync(CancellationToken)
Commits log entries into the underlying storage and marks these entries as committed.
Declaration
ValueTask<long> CommitAsync(CancellationToken token = default)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask<long> | The actual number of committed entries. |
Remarks
This method should updates cached value provided by method LastCommittedEntryIndex 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. |
CreateBackupAsync(Stream, CancellationToken)
Creates backup of this audit trail.
Declaration
Task CreateBackupAsync(Stream output, CancellationToken token = default)
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. |
DropAsync(long, CancellationToken)
Dropes the uncommitted entries starting from the specified position to the end of the log.
Declaration
ValueTask<long> DropAsync(long startIndex, CancellationToken token = default)
Parameters
Type | Name | Description |
---|---|---|
long | startIndex | The index of the first log entry to be dropped. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask<long> | The actual number of dropped entries. |
Exceptions
Type | Condition |
---|---|
InvalidOperationException |
|
OperationCanceledException | The operation has been canceled. |
InitializeAsync(CancellationToken)
Initializes audit trail.
Declaration
Task InitializeAsync(CancellationToken token = default)
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. |
ReadAsync<TResult>(ILogEntryConsumer<ILogEntry, TResult>, long, long, CancellationToken)
Gets log entries in the specified range.
Declaration
ValueTask<TResult> ReadAsync<TResult>(ILogEntryConsumer<ILogEntry, TResult> reader, long startIndex, long endIndex, CancellationToken token = default)
Parameters
Type | Name | Description |
---|---|---|
ILogEntryConsumer<ILogEntry, 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 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 |
|
IndexOutOfRangeException |
|
OperationCanceledException | The operation has been canceled. |
See Also
| Edit this page View SourceReadAsync<TResult>(ILogEntryConsumer<ILogEntry, TResult>, long, CancellationToken)
Gets log entries starting from the specified index to the last log entry.
Declaration
ValueTask<TResult> ReadAsync<TResult>(ILogEntryConsumer<ILogEntry, TResult> reader, long startIndex, CancellationToken token = default)
Parameters
Type | Name | Description |
---|---|---|
ILogEntryConsumer<ILogEntry, TResult> | reader | The reader of the log entries. |
long | 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 |
---|---|
TResult | The type of the result. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException |
|
OperationCanceledException | The operation has been canceled. |
See Also
| Edit this page View SourceWaitForCommitAsync(long, CancellationToken)
Waits for the commit.
Declaration
ValueTask WaitForCommitAsync(long index, CancellationToken token = default)
Parameters
Type | Name | Description |
---|---|---|
long | index | The index of the log record to be committed. |
CancellationToken | token | The token that can be used to cancel waiting. |
Returns
Type | Description |
---|---|
ValueTask | The task representing asynchronous result. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException |
|
OperationCanceledException | The operation has been cancelled. |
WaitForCommitAsync(CancellationToken)
Waits for the commit.
Declaration
ValueTask WaitForCommitAsync(CancellationToken token = default)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | token | The token that can be used to cancel waiting. |
Returns
Type | Description |
---|---|
ValueTask | The task representing asynchronous result. |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been cancelled. |