class

Raft::Node::Replicator

Inherits Reference < Object

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.

Constructors

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)
Source

Instance methods

ack(success : Bool) : Nil

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

Source
notify

Signals the replicator that new entries are available to send.

Non-blocking — drops the signal if the channel is already full (the pending notification is sufficient).

Source
start

Starts the replication fiber for this peer.

Source
stop

Stops the replication fiber, closing notification channels.

Source