Skip to main content

MetadataImage

Struct MetadataImage 

Source
pub struct MetadataImage { /* private fields */ }

Implementations§

Source§

impl MetadataImage

Source

pub fn new(cluster_id: Uuid) -> Self

Source

pub fn cluster_id(&self) -> Uuid

Source

pub fn topics(&self) -> impl Iterator<Item = &TopicRecord>

Source

pub fn topic(&self, name: &str) -> Option<&TopicRecord>

Source

pub fn topic_by_id(&self, id: &Uuid) -> Option<&TopicRecord>

KIP-516: resolve a topic by its UUID. O(1) via the topic_ids index.

Source

pub fn topic_name_by_id(&self, id: &Uuid) -> Option<&str>

KIP-516: resolve a topic name by its UUID.

Source

pub fn partition(&self, topic: &str, idx: i32) -> Option<&PartitionRecord>

Source

pub fn partitions_of( &self, topic: &str, ) -> impl Iterator<Item = &PartitionRecord>

Source

pub fn topic_partition_count(&self, topic: &str) -> i32

The live partition count for topic, derived from the partitions map rather than the stored TopicRecord.partitions field. This is the authoritative count for the KIP-631 round-trip (the KIP-631 TopicRecord carries no partition count) and for the validate partition-count-grew check. Returns 0 for an unknown topic or one with no partition records yet applied.

Source

pub fn all_partitions( &self, ) -> impl Iterator<Item = (&(String, i32), &PartitionRecord)>

Single-pass iterator over every partition in the image, yielding the flat (topic_name, partition_index) key alongside the record. O(P) in total partition count — the cluster-wide maintenance loops (failover, rebalance, reassignment, metrics) use this instead of topics().flat_map(partitions_of), which is O(topics × P).

Source

pub fn reassignments_in_flight( &self, ) -> impl Iterator<Item = &PartitionRecord> + '_

All partitions where a reassignment is currently in flight (adding_replicas or removing_replicas non-empty).

Source

pub fn topic_config(&self, topic: &str) -> Option<&BTreeMap<String, String>>

Currently-effective config overrides for topic, or None if no V1TopicConfig record has been applied for this topic since the last V1DeleteTopic (or since image creation).

Source

pub fn broker_config( &self, node_id: NodeId, ) -> Option<&BTreeMap<String, String>>

Per-broker config overrides for node_id, or None if no V1BrokerConfig record has been applied for this broker.

Source

pub fn broker_throttle_rate( &self, node_id: NodeId, kind: ThrottleKind, ) -> Option<u64>

Returns the throttle rate in bytes/sec for node_id and kind. Returns None if the config key is absent, unparseable, or is -1 (Kafka convention for “disabled / unlimited”).

Source

pub fn client_metrics_config( &self, name: &str, ) -> Option<&BTreeMap<String, String>>

Override map for a single KIP-714 client-metrics subscription.

Source

pub fn client_metrics_subscriptions( &self, ) -> impl Iterator<Item = (&String, &BTreeMap<String, String>)>

All configured client-metrics subscriptions, (name, overrides).

Source

pub fn client_quotas(&self) -> &HashMap<EntityKey, BTreeMap<String, f64>>

Source

pub fn scram_credential( &self, user: &str, mechanism: SaslMechanism, ) -> Option<&ScramCredential>

Source

pub fn scram_credentials_users(&self) -> Vec<String>

All distinct users with at least one SCRAM credential. Order is unspecified.

Source

pub fn scram_credentials_for_user( &self, user: &str, ) -> Vec<(SaslMechanism, u32)>

All (mechanism, iterations) pairs for user. Empty if user has no SCRAM credentials. Order is unspecified.

Source

pub fn broker(&self, node_id: NodeId) -> Option<&BrokerRegistrationRecord>

Source

pub fn broker_epoch(&self, node_id: NodeId) -> Option<i64>

KIP-903: the broker epoch (registration commit offset) for node_id, or None if the broker is not registered in this image.

Source

pub fn brokers(&self) -> impl Iterator<Item = &BrokerRegistrationRecord>

Source

pub fn kraft_version(&self) -> u16

Source

pub fn voters(&self) -> &VoterSet

Source

pub fn matching_acls<'a>( &'a self, rt: ResourceType, rn: &'a str, ) -> impl Iterator<Item = &'a AclEntry> + 'a

Iterate every ACL that could possibly match (rt, rn):

  • all literal entries at (rt, rn)
  • all literal entries at (rt, "*") — the WILDCARD_RESOURCE, which matches every resource of that type (see Kafka’s AclAuthorizer / StandardAuthorizer; this is what kafka-acls --topic '*' produces)
  • all prefixed entries whose resource_name is a prefix of rn
Source

pub fn all_acls(&self) -> impl Iterator<Item = &AclEntry>

All ACL entries (literal + prefixed across all resource types). Used by DescribeAcls.

Source

pub fn delegation_token_by_id(&self, token_id: &str) -> Option<&DelegationToken>

Look up a delegation token by its token_id (KIP-48).

Source

pub fn delegation_tokens_by_owner( &self, owner: &KafkaPrincipal, ) -> Vec<&DelegationToken>

All tokens owned by owner (KIP-48; exact match on the owning KafkaPrincipal). Order is unspecified.

Source

pub fn delegation_tokens_visible_to( &self, principal: &KafkaPrincipal, ) -> Vec<&DelegationToken>

Tokens that principal is allowed to see via DescribeDelegationToken without DescribeToken permission — either as the owner or as a listed renewer (KIP-48). Order is unspecified.

Source

pub fn all_delegation_tokens(&self) -> impl Iterator<Item = &DelegationToken>

Every delegation token currently in the image (KIP-48). Used by DescribeDelegationToken for callers with DescribeToken permission on the cluster.

Source

pub fn delegation_token_by_hmac(&self, hmac: &[u8]) -> Option<&DelegationToken>

KIP-48: lookup a delegation token by its HMAC bytes. RenewDelegationToken / ExpireDelegationToken identify a token by HMAC on the wire (not by token_id), and the SCRAM delegation-token fallback needs the same lookup at the auth path. Implementation is a linear scan over the small (per-broker, in-memory) token map — clarity over an explicit HMAC→token_id index until cardinality justifies it.

Source

pub fn finalized_features(&self) -> &BTreeMap<String, i16>

KIP-584: finalized feature levels, keyed by feature name. Empty until an UpdateFeatures call lands a V1FeatureLevel record.

Source

pub fn finalized_features_epoch(&self) -> i64

KIP-584 finalized-features epoch. -1 (“unknown”) until the first feature is finalized.

Source

pub fn finalized_metadata_version(&self) -> Option<i16>

The finalized metadata.version level, or None if no V1FeatureLevel for metadata.version has been applied (a pre-bootstrap / legacy image — MetadataVersion.UNKNOWN).

Source

pub fn finalized_feature(&self, name: &str) -> Option<i16>

KIP-584: the finalized level for an arbitrary feature, or None if it has not been finalized. Generic counterpart to Self::finalized_metadata_version.

Source

pub fn min_required_metadata_version(&self) -> i16

The minimum metadata.version level the live image requires: the floor a downgrade must not drop below. Rises with feature-gated state present in the image (KRaft SCRAM creds, delegation tokens). Baseline is METADATA_VERSION_MIN.

Source

pub fn apply(&mut self, rec: &MetadataRecord)

Apply one record. Returns the previous record (for V1Topic / V1BrokerRegistration) so the caller can observe overwrite cases. Infallible — pre-validation against the current image happens in the controller before submitting to Raft. Apply must never fail on a committed entry.

Source

pub fn to_records(&self) -> Vec<MetadataRecord>

Serialize the image into the minimal sequence of MetadataRecords whose in-order apply reproduces this image exactly. This is the inverse of apply over a sequence of non-tombstone records: each stored entry maps to the record that would create it.

Tombstone / removal records (V1DeleteTopic, V1DeleteScramCredential, V1DeleteAccessControlEntry, V1DeleteDelegationToken, V1UnregisterBroker) are intentionally never emitted: a snapshot captures resulting state, not deletion history. V1BrokerConfig deletes likewise vanish — only the surviving key/value pairs are emitted as Some(value) sets.

Records are emitted in dependency order so that a fresh image applying them never sees a dangling reference: brokers, broker-configs, topics, partitions, topic-configs, SCRAM creds, ACLs, client quotas, delegation tokens.

Source

pub fn from_records(cluster_id: Uuid, records: &[MetadataRecord]) -> Self

Reconstruct an image from a cluster_id and a record sequence (typically Self::to_records output read back from a snapshot): new an empty image and apply each record in order.

Source

pub fn validate(&self, rec: &MetadataRecord) -> Result<(), MetadataError>

Synchronous pre-validation: returns Ok if the record would be a no-conflict apply, otherwise the appropriate error. Used by Controller::submit_change before forwarding to openraft.

Trait Implementations§

Source§

impl Clone for MetadataImage

Source§

fn clone(&self) -> MetadataImage

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MetadataImage

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for MetadataImage

Source§

fn default() -> MetadataImage

Returns the “default value” for a type. Read more
Source§

impl PartialEq for MetadataImage

Source§

fn eq(&self, other: &MetadataImage) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for MetadataImage

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more