Skip to main content

Module kraft_translate

Module kraft_translate 

Source
Expand description

Translate Krabka’s internal MetadataRecord currency to and from the KIP-631 [KraftMetadataRecord] wire shape, so the controller log and snapshots are genuinely KIP-631-framed.

The conversion is not a pure field rename. Several Krabka records carry state that the KIP-631 records do not, and the reverse also holds. This module bridges the gap and defaults the KIP-631 extras that Krabka does not model. The round-trip rec -> to_kraft(&image) -> from_kraft(&image) == rec is the correctness bar for every modeled variant.

§Variants with no faithful KIP-631 counterpart

  • V1Voters and V1KRaftVersion are KIP-853 raft control records and not metadata records. They have no entry in the [KraftMetadataRecord] dispatch, and nothing submits them through the translation boundary, so to_kraft returns TranslateError::NoCounterpart for them.

§Fan-out / image-keyed mappings

  • V1TopicConfig is whole-map authoritative, and KIP-631 has only per-key ConfigRecords. to_kraft_records diffs the new map against the current overrides of the image. It emits a set per present key plus a tombstone (value: None) per dropped key. from_kraft merges the delta of one key back onto the image map and re-emits the whole map, so the replace semantics of MetadataImage::apply stay unchanged. Records must apply in log order against a live image.
  • V1DeleteAccessControlEntry(AclEntryFilter): KIP-631’s RemoveAccessControlEntryRecord deletes by id: Uuid only. Krabka does not model ACL ids, so to_kraft_records resolves the filter against the image to the matching entries and emits one RemoveAccessControlEntry per match, keyed by a deterministic content-hash id. That is the same id that the add path stamps. from_kraft rescans the image by that hash to recover the entry and emit a pinned filter. This is self-consistent within Krabka.

§Lossy / awkward mappings (documented)

  • RegisterBroker: Krabka stores a top-level (host, port) plus a per-listener endpoints list; KIP-631 has only end_points (no top-level host/port). When listeners exist, their first entry supplies the legacy top-level pair on decode. A legacy Krabka record with no listeners uses one empty-name compatibility entry. broker_epoch, incarnation_id, features, log_dirs, fenced, in_controlled_shutdown and cordoned_log_dirs are carried; the ZK migration flag is dropped.
  • DelegationToken: KafkaPrincipals map through their Type:Name string form.

Enums§

TranslateError

Constants§

PRIVATE_RECORD_VERSION
The version of a krabka-private NoOpRecord tag body, the big-endian i16 in front of the wincode MetadataRecord. It is part of the krabka 1.x on-disk contract.

Functions§

from_kraft
Convert one KIP-631 record back to its MetadataRecord counterpart.
from_kraft_value
The inverse framing entrypoint.
to_kraft
Convert a single MetadataRecord to its KIP-631 counterpart.
to_kraft_records
Convert a single MetadataRecord to one or more KIP-631 records.
to_kraft_values
The engine/snapshot framing entrypoint: translate one MetadataRecord to the KIP-631 value byte blobs to put on the log.