Class RaftClusterExtensions
Represents extension methods for IRaftCluster interface.
Inherited Members
Namespace: DotNext.Net.Cluster.Consensus.Raft
Assembly: DotNext.Net.Cluster.dll
Syntax
public static class RaftClusterExtensions
Methods
| Edit this page View SourceReplicateAsync(IRaftCluster, ReadOnlyMemory<byte>, object?, CancellationToken)
Appends binary log entry and ensures that it is replicated and committed.
Declaration
public static ValueTask<bool> ReplicateAsync(this IRaftCluster cluster, ReadOnlyMemory<byte> payload, object? context = null, CancellationToken token = default)
Parameters
Type | Name | Description |
---|---|---|
IRaftCluster | cluster | The cluster node. |
ReadOnlyMemory<byte> | payload | The log entry payload. |
object | context | The context to be passed to the state machine. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask<bool> | true if the appended log entry has been committed by the majority of nodes; false if retry is required. |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | The current node is not a leader. |
OperationCanceledException | The operation has been canceled. |
ReplicateAsync<T>(IRaftCluster, T, object?, CancellationToken)
Appends binary log entry and ensures that it is replicated and committed.
Declaration
public static ValueTask<bool> ReplicateAsync<T>(this IRaftCluster cluster, T payload, object? context = null, CancellationToken token = default) where T : IBinaryFormattable<T>
Parameters
Type | Name | Description |
---|---|---|
IRaftCluster | cluster | The cluster node. |
T | payload | The log entry payload. |
object | context | The context to be passed to the state machine. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask<bool> | true if the appended log entry has been committed by the majority of nodes; false if retry is required. |
Type Parameters
Name | Description |
---|---|
T | The type of the binary formattable log entry. |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | The current node is not a leader. |
OperationCanceledException | The operation has been canceled. |
ReplicateJsonAsync<T>(IRaftCluster, T, object?, CancellationToken)
Appends JSON log entry and ensures that it is replicated and committed.
Declaration
public static ValueTask<bool> ReplicateJsonAsync<T>(this IRaftCluster cluster, T payload, object? context = null, CancellationToken token = default) where T : IJsonSerializable<T>
Parameters
Type | Name | Description |
---|---|---|
IRaftCluster | cluster | The cluster node. |
T | payload | The log entry payload. |
object | context | The context to be passed to the state machine. |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask<bool> | true if the appended log entry has been committed by the majority of nodes; false if retry is required. |
Type Parameters
Name | Description |
---|---|
T | The type of the JSON log entry. |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | The current node is not a leader. |
OperationCanceledException | The operation has been canceled. |