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 SourceCommitAsync(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. |
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. |
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. |
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.
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. |
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 |
|
IndexOutOfRangeException |
|
See Also
| Improve this Doc View SourceReadAsync<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 |
|
See Also
| Improve this Doc View SourceWaitForCommitAsync(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 |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException |
|
OperationCanceledException | The operation has been cancelled. |
TimeoutException | Timeout occurred. |
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. |