class
Raft::Transport::TCP
- Raft::Transport::TCP
- Raft::Transport
- Reference
- Object
Overview
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.
Defined in:
raft/transport/tcp.crConstructors
Instance Method Summary
-
#actual_port : Int32
Returns the actual port the server is listening on.
-
#send(peer_id : String, message : RPC::Message) : Nil
Sends an RPC message to the peer identified by peer_id.
-
#start(inbox : Channel(RPC::Envelope)) : Nil
Starts listening for incoming messages.
-
#stop : Nil
Shuts down the transport, closing all connections and listeners.
Instance methods inherited from class Raft::Transport
send(peer_id : String, message : RPC::Message) : Nil
send,
start(inbox : Channel(RPC::Envelope)) : Nil
start,
stop : Nil
stop
Constructor Detail
Instance Method Detail
Returns the actual port the server is listening on.
Useful when binding to port 0 (OS-assigned) in tests.
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.
Starts listening for incoming messages.
Received messages are wrapped in RPC::Envelope (tagged with sender ID)
and pushed into the provided inbox channel.
Shuts down the transport, closing all connections and listeners.