class Raft::Node::Replicator

Overview

Per-peer log replication fiber with pipelined AppendEntries.

Each replicator runs in its own fiber and sends AppendEntries RPCs to a single follower. It maintains an optimistic @pipeline_next_index cursor that can run ahead of the confirmed @next_index, allowing up to Config#max_inflight_rpcs batches to be in-flight simultaneously. The leader event loop signals each ack back via #ack so the replicator can send the next batch without waiting for the heartbeat timeout.

When the follower is too far behind, the replicator sends the snapshot in chunks via InstallSnapshot and resets the pipeline cursor.

Defined in:

raft/node/replicator.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(peer_id : String, node_id : String, transport : Transport, log : Log, current_term : UInt64, next_index : Hash(String, UInt64), commit_index : Pointer(UInt64), config : Config) #

[View source]

Instance Method Detail

def ack(success : Bool) : Nil #

Called by the leader event loop after each AppendEntriesResponse. success false resets the pipeline cursor to the last confirmed position.


[View source]
def notify : Nil #

[View source]
def start : Nil #

[View source]
def stop : Nil #

[View source]