Class PersistentStateExtensions
Provides various extension methods for IPersistentState interface.
Inherited Members
Namespace: DotNext.Net.Cluster.Consensus.Raft
Assembly: DotNext.Net.Cluster.dll
Syntax
public static class PersistentStateExtensions
Methods
| Edit this page View SourceAppendAsync(IPersistentState, ReadOnlyMemory<byte>, object?, CancellationToken)
Appends a block of bytes to the log tail.
Declaration
public static ValueTask<long> AppendAsync(this IPersistentState state, ReadOnlyMemory<byte> payload, object? context = null, CancellationToken token = default)
Parameters
| Type | Name | Description |
|---|---|---|
| IPersistentState | state | The log. |
| ReadOnlyMemory<byte> | payload | The log entry payload. |
| object | context | The optional context to be passed to the state machine. |
| CancellationToken | token | The token that can be used to cancel the operation. |
Returns
| Type | Description |
|---|---|
| ValueTask<long> | The index of the added command within the log. |
AppendAsync<T>(IPersistentState, T, object?, CancellationToken)
Appends a binary object to the log tail.
Declaration
public static ValueTask<long> AppendAsync<T>(this IPersistentState state, T payload, object? context = null, CancellationToken token = default) where T : IBinaryFormattable<T>
Parameters
| Type | Name | Description |
|---|---|---|
| IPersistentState | state | The log. |
| T | payload | The log entry payload. |
| object | context | The optional context to be passed to the state machine. |
| CancellationToken | token | The token that can be used to cancel the operation. |
Returns
| Type | Description |
|---|---|
| ValueTask<long> | The index of the added command within the log. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the binary object. |
AppendJsonAsync<T>(IPersistentState, T, object?, CancellationToken)
Appends JSON objec to the log tail.
Declaration
public static ValueTask<long> AppendJsonAsync<T>(this IPersistentState state, T payload, object? context = null, CancellationToken token = default) where T : IJsonSerializable<T>
Parameters
| Type | Name | Description |
|---|---|---|
| IPersistentState | state | The log. |
| T | payload | The log entry payload. |
| object | context | The optional context to be passed to the state machine. |
| CancellationToken | token | The token that can be used to cancel the operation. |
Returns
| Type | Description |
|---|---|
| ValueTask<long> | The index of the added command within the log. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the binary object. |