Interface IAuditTrail<TEntry>
Represents audit trail responsible for maintaining log entries.
Inherited Members
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 SourceAppendAndCommitAsync<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 |
| 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 |
|
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 |
| 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 |
|
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 |
|
| OperationCanceledException | The operation has been canceled. |
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 |
|
| OperationCanceledException | The operation has been canceled. |
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 |
|
| IndexOutOfRangeException |
|
| OperationCanceledException | The operation has been canceled. |