Struct PersistentState.LogEntry
Represents persistent log entry.
Inherited Members
Namespace: DotNext.Net.Cluster.Consensus.Raft
Assembly: DotNext.Net.Cluster.dll
Syntax
protected readonly struct PersistentState.LogEntry : IInputLogEntry, IRaftLogEntry, ILogEntry, IDataTransferObject
Remarks
Use TransformAsync<TResult, TTransformation>(TTransformation, CancellationToken) to decode the log entry.
Properties
| Edit this page View SourceCommandId
Gets identifier of the command encapsulated by this log entry.
Declaration
public int? CommandId { get; }
Property Value
Type | Description |
---|---|
int? |
Context
Gets or sets context associated with this log entry.
Declaration
public object? Context { get; init; }
Property Value
Type | Description |
---|---|
object |
Index
Gets the index of this log entry.
Declaration
public long Index { get; }
Property Value
Type | Description |
---|---|
long |
IsSnapshot
Gets a value indicating that this entry is a snapshot entry.
Declaration
public bool IsSnapshot { get; }
Property Value
Type | Description |
---|---|
bool |
Length
Gets length of the log entry content, in bytes.
Declaration
public long Length { get; }
Property Value
Type | Description |
---|---|
long |
Term
Gets Raft term of this log entry.
Declaration
public long Term { get; }
Property Value
Type | Description |
---|---|
long |
Timestamp
Gets timestamp of this log entry.
Declaration
public DateTimeOffset Timestamp { get; }
Property Value
Type | Description |
---|---|
DateTimeOffset |
Methods
| Edit this page View SourceGetReader()
Gets reader that can be used to deserialize the content of this log entry.
Declaration
public IAsyncBinaryReader GetReader()
Returns
Type | Description |
---|---|
IAsyncBinaryReader | The binary reader providing access to the content of this log entry. |
TransformAsync<TResult, TTransformation>(TTransformation, CancellationToken)
Converts data transfer object to another type.
Declaration
public ValueTask<TResult> TransformAsync<TResult, TTransformation>(TTransformation transformation, CancellationToken token) where TTransformation : notnull, IDataTransferObject.ITransformation<TResult>
Parameters
Type | Name | Description |
---|---|---|
TTransformation | transformation | The parser instance. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask<TResult> | The converted DTO content. |
Type Parameters
Name | Description |
---|---|
TResult | The type of result. |
TTransformation | The type of parser. |
Remarks
The default implementation copies the content into memory before parsing.
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The operation has been canceled. |
TryGetMemory(out ReadOnlyMemory<byte>)
Attempts to obtain the payload of this log entry in the form of the memory block.
Declaration
public bool TryGetMemory(out ReadOnlyMemory<byte> memory)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlyMemory<byte> | memory | The memory block representing the log entry payload. |
Returns
Type | Description |
---|---|
bool | true if the log entry payload is available as a memory block; otherwise, false. |
Remarks
This method returns false if the log entry is not cached in the memory. Use TransformAsync<TResult, TTransformation>(TTransformation, CancellationToken) as a uniform way to deserialize this payload.