class

Raft::Transport::TCP

Inherits Raft::Transport < Reference < Object

TCP transport with TLV framing, HMAC-SHA256 authentication, and connection pooling.

Maintains one persistent TCP connection per peer, lazily established on the first send. Failed connections are retried with exponential backoff (100ms initial, doubling up to 10s). Inbound connections are authenticated via Transport::Handshake before any messages are exchanged.

Constructors

Instance methods

actual_port

Returns the actual port the server is listening on.

Useful when binding to port 0 (OS-assigned) in tests.

Source
send(peer_id : String, message : RPC::Message) : Nil

Sends an RPC message to the peer identified by peer_id.

Delivery is best-effort. If the peer is unreachable the message is silently dropped — Raft's protocol-level retries handle the loss.

Source
start(inbox : Channel(RPC::Envelope)) : Nil

Starts listening for incoming messages.

Received messages are wrapped in RPC::Envelope (tagged with sender ID) and pushed into the provided inbox channel.

Source
stop

Shuts down the transport, closing all connections and listeners.

Source