Expand description
Versioned metadata records and the immutable image they apply to.
krabka-metadata provides MetadataRecord, the versioned union
of topic, partition, broker-registration, and topic-deletion records, and
MetadataImage, an immutable snapshot of the cluster’s metadata.
Only MetadataImage::apply mutates the image, and the Raft state
machine in krabka-raft calls that method. Everywhere else reads it
through shared references and Arc clones.
§Applying controller records
use krabka_metadata::{MetadataImage, MetadataRecord, TopicRecord};
use uuid::Uuid;
let mut image = MetadataImage::new(Uuid::new_v4());
let topic_id = Uuid::new_v4();
image.apply(&MetadataRecord::V1Topic(TopicRecord {
name: "orders".into(),
topic_id,
partitions: 0,
replication_factor: 3,
}));
let topic = image.topic("orders").expect("topic exists");
assert_eq!(topic.topic_id, topic_id);§Canonical quota entity keys
use krabka_metadata::canonicalize_entity;
let key = canonicalize_entity(vec![
("user".to_string(), Some("alice".to_string())),
("client-id".to_string(), Some("analytics".to_string())),
]);
assert_eq!(key[0].0, "client-id");
assert_eq!(key[1].0, "user");Re-exports§
pub use acl::AclEntry;pub use acl::AclEntryFilter;pub use acl::AclOperation;pub use acl::PatternType;pub use acl::PermissionType;pub use acl::ResourceType;pub use break_glass::BreakGlassAction;pub use break_glass::BreakGlassApproval;pub use break_glass::BreakGlassProposalRecord;pub use kafka_record::KafkaRecordError;pub use kafka_record::from_kafka_record;pub use kafka_record::to_kafka_record;pub use krabka_version::KrabkaVersion;pub use krabka_version::PrivateRpc;pub use krabka_version::private_rpc_version;pub use kraft_translate::PRIVATE_RECORD_VERSION;pub use kraft_translate::TranslateError;pub use kraft_translate::from_kraft;pub use kraft_translate::from_kraft_value;pub use kraft_translate::to_kraft;pub use kraft_translate::to_kraft_records;pub use kraft_translate::to_kraft_values;pub use write_freeze::TopicFreezeRecord;pub use krabka_voters as voters;
Modules§
- acl
- Wire-stable ACL types replicated through the raft quorum
with
MetadataRecord::V1AccessControlEntryandV1DeleteAccessControlEntry. - break_
glass - Break-glass proposal records, replicated through the raft quorum with
MetadataRecord::V1BreakGlassProposalandV1DeleteBreakGlassProposal. - directory_
id - KIP-858 reserved log-directory ids, transcribed from Kafka’s
org.apache.kafka.common.DirectoryId. - group_
version - KIP-848
group.versionfeature-level constants. - kafka_
record - Bridge between
MetadataRecordand a Kafka [Record] whose value is the wincode encoding of the record. - krabka_
version - The krabka-owned
krabka.versionfeature (KIP-584). - kraft_
translate - Translate Krabka’s internal
MetadataRecordcurrency to and from the KIP-631 [KraftMetadataRecord] wire shape, so the controller log and snapshots are genuinely KIP-631-framed. - metadata_
version - KIP-778
metadata.versionfeature-level model. - transaction_
version - KIP-890
transaction.versionfeature-level constants, matching Kafka’sTransactionVersion, which definesTV_0toTV_2only. - write_
freeze - Topic write-freeze registry entries, replicated through the raft quorum
with
MetadataRecord::V1TopicFreeze.
Structs§
- Broker
Config Record - Per-broker configuration key/value pair.
Some(value)= set;None= delete. - Broker
Endpoint - A single named listener endpoint advertised by a broker.
- Broker
Registration Change Record - Kafka’s
BrokerRegistrationChangeRecord(metadata apiKey 17): a delta on the registration of one broker. - Broker
Registration Record - Client
Metrics Config Record - KIP-714 client-metrics subscription config.
- Client
Quota Record - Controller
Registration Record - KIP-919 controller registration persisted in the metadata log.
- Delegation
Token - In-memory image type for a single delegation
token (KIP-48). Mirrors
DelegationTokenRecordwithout any tombstone concerns. The apply path handles tombstones as removals. - Delegation
Token Record - A single delegation token’s authoritative state (KIP-48).
- Delete
Delegation Token Record - Tombstone record that removes a delegation token (KIP-48)
from the image. The
ExpireDelegationTokenhandlers and the background expiry sweep emit it. - Delete
Scram Credential Record - Delete
Topic Record - Feature
Level Record - KIP-584 finalized feature level.
- Features
Epoch Record - Snapshot-only carrier for the KIP-584 finalized-features epoch.
- Group
Config Record - KIP-1071 dynamic configuration for one group resource. Each record is the
authoritative override map for
group_id; an empty map clears the resource. - KRaft
Version Range - Supported kraft.version range for a voter. The range is inclusive.
- KRaft
Version Record - KIP-853: finalizes the cluster-wide kraft.version feature level.
- Leader
Epoch - A partition leader epoch. KIP-320 wire type:
int32. - Metadata
Image - NodeId
- A broker, node, replica, or controller identifier.
- Partition
DirAssignment Record - KIP-858 directory-assignment delta.
- Partition
ElrRecord - KIP-966 eligible-leader state for one partition. Empty vectors clear it.
- Partition
Offset Advance Record - Diskless offset-sequencer delta: advance a partition’s committed
next-offset by
count. - Partition
Record - Partition
Recovery Record - Partition
Update Record - A Kafka
PartitionChangeRecordcan carry assignment, ELR, and recovery changes together. This record preserves that atomic update on replay. - Producer
IdsRecord - Durable controller state for cluster-wide producer-ID block allocation.
next_producer_idis the first ID not covered by any committed block. - Quota
Entity - Scram
Credential Record - Topic
Config Record - Mutable topic configuration overrides.
- Topic
Record - Unregister
Broker Record - KIP-919 /
UnregisterBroker(api_key64), Kafka’sUnregisterBrokerRecord(metadata apiKey 1). - Unregister
Controller Record - KIP-1312
UnregisterController(api_key94), Kafka trunk’sUnregisterControllerRecord(metadata apiKey 29). - Voter
- One voter’s full identity.
- Voter
Endpoint - A single listener endpoint advertised by a voter.
- Voter
Set - The authoritative voter set, ordered by node id.
- Voters
Record - KIP-853: full snapshot of the controller voter set.
Enums§
- Fencing
Change - A change to the fencing state of a broker registration, as Kafka’s
BrokerRegistrationFencingChangeencodes it inBrokerRegistrationChangeRecord.Fenced. - Leader
Recovery State - KIP-704 state of an uncleanly elected leader.
- Metadata
Error - Metadata
Record - Throttle
Kind - Selects which broker byte-rate config key to read.
Constants§
- DEFAULT_
BROKER_ CONFIG_ NODE_ ID - Internal identity for Kafka’s cluster-wide default broker-config resource. Broker IDs are non-negative signed 32-bit integers on the Kafka wire, so this value cannot collide with a real broker.
Traits§
- Feature
- One versioned cluster feature (KIP-584).
Functions§
- bootstrap_
feature_ records - KIP-584/1022 bootstrap: one
V1FeatureLevelrecord per registered feature at its per-release default, derived frombootstrap_mv, the bootstrap metadata.version level. - bootstrap_
feature_ records_ with_ overrides - KIP-1022
krabka formatseeding: oneV1FeatureLevelrecord per registered feature. - canonicalize_
entity - feature
- Look up a registered feature by name.
- feature_
registry - All features this broker supports finalizing. Single source of truth.
- is_
supported_ level - True if
levelis within the registered feature’s supported range.falsefor an unknown feature (nothing supports that level). - supported_
feature_ ranges - Supported feature ranges advertised by a Krabka broker or controller when
it registers with the
KRaftcontroller. - validate_
feature_ dependencies - KIP-1022 dependency validation for a fully-resolved feature→level map, as
seeded by
krabka format.