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. |
Properties
| Improve this Doc View SourceFirst
Gets the first ephemeral log entry that is present in the empty log.
Declaration
TEntry First { get; }
Property Value
Type | Description |
---|---|
TEntry |
Remarks
The first log entry always represents NOP database command and is already committed. Index of such entry is always 0.
Methods
| Improve this Doc View SourceAppendAsync<TEntryImpl>(TEntryImpl, Int64)
Adds uncommitted log entry to the end of this log.
Declaration
ValueTask AppendAsync<TEntryImpl>(TEntryImpl entry, long startIndex)
where TEntryImpl : TEntry
Parameters
Type | Name | Description |
---|---|---|
TEntryImpl | entry | The uncommitted log entry to be added into this audit trail. |
Int64 | startIndex | The index from which all previous log entries should be dropped and replaced with the new entry. |
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>, Int64, Boolean, CancellationToken).
Exceptions
Type | Condition |
---|---|
InvalidOperationException |
|
AppendAsync<TEntryImpl>(TEntryImpl, CancellationToken)
Adds uncommitted log entry to the end of this log.
Declaration
virtual ValueTask<long> AppendAsync<TEntryImpl>(TEntryImpl entry, CancellationToken token = default(CancellationToken))
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<Int64> | 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 |
|
AppendAsync<TEntryImpl>(ILogEntryProducer<TEntryImpl>, Int64, Boolean, CancellationToken)
Adds uncommitted log entries into this log.
Declaration
ValueTask AppendAsync<TEntryImpl>(ILogEntryProducer<TEntryImpl> entries, long startIndex, bool skipCommitted = false, CancellationToken token = default(CancellationToken))
where TEntryImpl : TEntry
Parameters
Type | Name | Description |
---|---|---|
ILogEntryProducer<TEntryImpl> | entries | Stateful object that is responsible for supplying log entries. |
Int64 | startIndex | The index from which all previous log entries should be dropped and replaced with new entries. |
Boolean | 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. |
Remarks
The supplying function must return null if it cannot provide more log entries.
Exceptions
Type | Condition |
---|---|
InvalidOperationException |
|
AppendAsync<TEntryImpl>(ILogEntryProducer<TEntryImpl>, CancellationToken)
Adds uncommitted log entries to the end of this log.
Declaration
ValueTask<long> AppendAsync<TEntryImpl>(ILogEntryProducer<TEntryImpl> entries, CancellationToken token = default(CancellationToken))
where TEntryImpl : TEntry
Parameters
Type | Name | Description |
---|---|---|
ILogEntryProducer<TEntryImpl> | entries | The entries to be added into this log. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask<Int64> | The index of the first added entry. |
Type Parameters
Name | Description |
---|---|
TEntryImpl | The actual type of the log entry returned by the supplier. |
Remarks
This method should updates cached value provided by method GetLastIndex(Boolean) called with argument of value false.
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
InvalidOperationException | The collection of entries contains the snapshot entry. |
DropAsync(Int64, 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(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Int64 | 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<Int64> | The actual number of dropped entries. |
Exceptions
Type | Condition |
---|---|
InvalidOperationException |
|
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<TEntry, 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<TEntry, 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
Explicit Interface Implementations
| Improve this Doc View SourceIAuditTrail.ReadAsync<TReader, TResult>(TReader, Int64, Int64, CancellationToken)
Declaration
ValueTask<TResult> IAuditTrail.ReadAsync<TReader, TResult>(TReader reader, long startIndex, long endIndex, CancellationToken token)
where TReader : ILogEntryConsumer<ILogEntry, TResult>
Parameters
Type | Name | Description |
---|---|---|
TReader | reader | |
Int64 | startIndex | |
Int64 | endIndex | |
CancellationToken | token |
Returns
Type | Description |
---|---|
ValueTask<TResult> |
Type Parameters
Name | Description |
---|---|
TReader | |
TResult |
IAuditTrail.ReadAsync<TReader, TResult>(TReader, Int64, CancellationToken)
Declaration
ValueTask<TResult> IAuditTrail.ReadAsync<TReader, TResult>(TReader reader, long startIndex, CancellationToken token)
where TReader : ILogEntryConsumer<ILogEntry, TResult>
Parameters
Type | Name | Description |
---|---|---|
TReader | reader | |
Int64 | startIndex | |
CancellationToken | token |
Returns
Type | Description |
---|---|
ValueTask<TResult> |
Type Parameters
Name | Description |
---|---|
TReader | |
TResult |