Show / Hide Table of Contents

Class RaftClusterExtensions

Represents extension methods for IRaftCluster interface.

Inheritance
object
RaftClusterExtensions
Inherited Members
object.GetType()
object.MemberwiseClone()
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
Namespace: DotNext.Net.Cluster.Consensus.Raft
Assembly: DotNext.Net.Cluster.dll
Syntax
public static class RaftClusterExtensions

Methods

View Source

ApplyReadBarrierAsync(IRaftCluster, CancellationToken)

Ensures linearizable read from underlying state machine.

Declaration
public static ValueTask ApplyReadBarrierAsync(this IRaftCluster cluster, CancellationToken token = default)
Parameters
Type Name Description
IRaftCluster cluster
CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask

The task representing asynchronous result.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

QuorumUnreachableException

The quorum is not visible to the local node.

View Source

ReplicateAsync(IRaftCluster, ReadOnlyMemory<byte>, object?, CancellationToken)

Appends binary log entry and ensures that it is replicated and committed.

Declaration
public static ValueTask ReplicateAsync(this IRaftCluster cluster, ReadOnlyMemory<byte> payload, object? context = null, CancellationToken token = default)
Parameters
Type Name Description
IRaftCluster cluster
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

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.

View Source

ReplicateAsync<T>(IRaftCluster, T, object?, CancellationToken)

Appends binary log entry and ensures that it is replicated and committed.

Declaration
public static ValueTask ReplicateAsync<T>(this IRaftCluster cluster, T payload, object? context = null, CancellationToken token = default) where T : notnull, IBinaryFormattable<T>
Parameters
Type Name Description
IRaftCluster cluster
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

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.

View Source

ReplicateJsonAsync<T>(IRaftCluster, T, object?, CancellationToken)

Appends JSON log entry and ensures that it is replicated and committed.

Declaration
public static ValueTask ReplicateJsonAsync<T>(this IRaftCluster cluster, T payload, object? context = null, CancellationToken token = default) where T : notnull, IJsonSerializable<T>
Parameters
Type Name Description
IRaftCluster cluster
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

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.

View Source

get_Term(IRaftCluster)

Gets term number used by Raft algorithm to check the consistency of the cluster.

Declaration
public static long get_Term(IRaftCluster cluster)
Parameters
Type Name Description
IRaftCluster cluster
Returns
Type Description
long
  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾