RaftTransport

interface RaftTransport

The messaging seam between the Raft engine and any underlying network layer.

RaftTransport decouples the engine from the wire — the same engine code runs over WebSocket (SeamRaftTransport), in-process channels (tests), or any other point-to-point fabric. Implement this interface to plug in a custom transport.

Reachability vs. membership. peers reflects which nodes the transport can currently reach, not which nodes are configured voters. A node may be a configured voter but momentarily absent from peers (network partition), or absent from the cluster config entirely (unknown peer). The engine handles both cases.

Single collection. incoming is a hot flow; collect it once. The engine calls RaftTransport.incoming exactly once per RaftNode lifetime.

Inheritors

Properties

Link copied to clipboard
abstract val incoming: Flow<RaftEnvelope>

Hot flow of inbound RaftEnvelopes from other cluster members.

Link copied to clipboard
open val maxPayloadBytes: Int?

The maximum number of bytes a single sendTo payload can carry, or null if effectively unbounded (e.g. WebSocket). Fabrics with hard framing limits (e.g. ~32 KiB on some LAN radios) return that limit so kuilt-raft can size InstallSnapshot chunks to fit. Defaulted — existing transports need no change.

Link copied to clipboard
abstract val peers: StateFlow<Set<NodeId>>

The set of peers currently reachable via this transport.

Link copied to clipboard
abstract val selfId: NodeId

This node's own stable identifier. Must match its entry in ClusterConfig.

Functions

Link copied to clipboard
abstract suspend fun sendTo(peer: NodeId, message: ByteArray)

Sends message to peer.