krabka_raft/kraft/transport.rs
1//! Transport seam for the [`KraftController`](crate::kraft::controller::KraftController).
2//!
3//! Outbound peer RPCs go through [`PeerSender`], which is real TCP in
4//! production and in-memory in tests. Inbound KIP-595 RPCs arrive as
5//! [`Inbound`], which carries a oneshot reply channel. Handle-facing requests
6//! arrive as [`Command`].
7//!
8//! This module is the wire-agnostic boundary: the event loop never touches
9//! sockets directly. In-memory tests and real TCP both implement `PeerSender`
10//! against the same command and inbound plumbing.
11//!
12//! ## Peer codec
13//!
14//! Peer RPC request and response bodies are encoded with the generated KIP-595
15//! message codecs in [`wire`]. The engine encodes a `PeerRequest` into the body
16//! it hands to [`PeerSender::send`]. The receiving transport drives the peer
17//! engine and returns a `PeerResponse`. The sending engine then decodes that
18//! response into the matching core [`Event`](crate::kraft::event::Event), which
19//! is `ReceiveVoteResponse` or `ReceiveFetchResponse`. This keeps the send path
20//! fire-and-forget: the engine never `.await`s a peer RPC inline.
21
22mod command;
23mod peer_sender;
24
25pub mod api_key;
26pub mod wire;
27
28pub use self::{
29 api_key::PeerApi,
30 command::{
31 Command, CommandSender, Inbound, MetadataFetchSlice, ObserverReplica, QueuedCommand,
32 QuorumStateSnapshot, TimerTick,
33 },
34 peer_sender::{NullPeerSender, PeerSender},
35};