Expand description
Real KIP-595 peer-RPC body codec.
The engine’s loop reasons in terms of the flat PeerRequest and
PeerResponse enums. This module maps each variant to and from the genuine
generated KIP-595 message bodies. Those bodies are header-less, because the
framing layer in server.rs and network.rs adds the request header and
the response header. The captured wire versions are Vote v2,
BeginQuorumEpoch v1, EndQuorumEpoch v1, and Fetch v18. Krabka-to-Krabka
replication rides these exact bytes.
The metadata log is the single KRaft topic __cluster_metadata, partition
0, so every RPC body carries exactly one topic and exactly one partition.
Kafka’s VoteResponse carries no pre-vote field. A candidate matches a
reply to its round from its own Prospective or Candidate role, so Krabka
encodes a byte-faithful VoteResponse and the core infers the round itself
(KIP-996).
The shared constants and integer conversions live in codec, the request
bodies in request, and the response bodies in response.
Structs§
- Fetch
Answer - A Fetch answer, in the one shape Kafka’s
KafkaRaftClient.buildFetchResponsegives both a served fetch and a refused one. - Fetch
Snapshot Partition - The one partition of a
FetchSnapshotanswer that names a partition. - Leader
Endpoint - The host and port a leader is reached at.
- Preferred
Candidate - A voter that an
EndQuorumEpochnames as a preferred successor. - Quorum
Leader - What a quorum RPC response says about the responder’s view of the leader,
as Kafka’s
RaftUtil.singleton*Responsehelpers fill it. - Snapshot
Chunk - A served chunk of a snapshot.
Enums§
- Peer
Request - A peer RPC request body, as encoded by the sending engine and decoded by the receiving engine’s inbound dispatch.
- Peer
Response - A peer RPC response body. The sending engine decodes it back into the
matching
Receive*Responseevent, or applies it directly for Fetch.
Constants§
- FETCH_
SNAPSHOT_ VERSION - The versions
PeerRequestencodes each peer RPC at. Public because a broker-only observer sendsFetchSnapshotitself, and the version on its request header has to be the one the body was encoded at. - FETCH_
VERSION - The versions
PeerRequestencodes each peer RPC at. Public because a broker-only observer sendsFetchSnapshotitself, and the version on its request header has to be the one the body was encoded at. - QUORUM_
EPOCH_ VERSION - The versions
PeerRequestencodes each peer RPC at. Public because a broker-only observer sendsFetchSnapshotitself, and the version on its request header has to be the one the body was encoded at. - VOTE_
VERSION - The versions
PeerRequestencodes each peer RPC at. Public because a broker-only observer sendsFetchSnapshotitself, and the version on its request header has to be the one the body was encoded at. Captured flexible wire versions, byte-validated against fixture frames.
Functions§
- decode_
begin - Decodes a
BeginQuorumEpochrequest body (api 53). - decode_
end - Decodes an
EndQuorumEpochrequest body (api 54). - decode_
fetch - Decodes a Fetch request body (api 1).
- decode_
fetch_ snapshot - Decodes a
FetchSnapshotrequest body (api 59). - decode_
vote - Decodes a Vote request body (api 52).
- encode_
begin_ quorum_ epoch_ response - Encodes a
BeginQuorumEpochresponse body (api 53) atversion, with the same shape rules asencode_vote_response. - encode_
end_ quorum_ epoch_ response - Encodes an
EndQuorumEpochresponse body (api 54) atversion, with the same shape rules asencode_vote_response. - encode_
fetch_ snapshot_ answer - Encodes a
FetchSnapshotresponse body (api 59) atversion, as Kafka’sRaftUtil.singletonFetchSnapshotResponsebuilds it. - encode_
fetch_ top_ level_ error - Encodes Kafka’s bare top-level Fetch error response at
version:new FetchResponseData().setErrorCode(error), with no topic. - encode_
vote_ response - Encodes a Vote response body (api 52) at
version, the version of the request it answers. - fetch_
replica_ id - Kafka’s
FetchRequest.replicaId: the top-levelReplicaIdup to v14, theReplicaStatefrom v15.