pub struct Metadata { /* private fields */ }Expand description
What the client knows about the cluster.
Implementations§
Source§impl Metadata
impl Metadata
pub fn new() -> Self
Sourcepub fn update(&mut self, resp: &MetadataResponse)
pub fn update(&mut self, resp: &MetadataResponse)
Merge a MetadataResponse in.
Merge rather than replace: a response for one topic says nothing about the others, and replacing would silently drop leadership the client is actively using. Partitions carrying an error code are skipped, not recorded as leaderless — an error means “ask again”, and writing it down would cache the failure.
Sourcepub fn leader_for(&self, topic: &str, partition: i32) -> Option<&BrokerAddr>
pub fn leader_for(&self, topic: &str, partition: i32) -> Option<&BrokerAddr>
Where to send a request for this partition, if known.
Sourcepub fn broker(&self, node_id: i32) -> Option<&BrokerAddr>
pub fn broker(&self, node_id: i32) -> Option<&BrokerAddr>
Look a broker up by node id — how a coordinator, which is named by id rather than address, is reached.
Sourcepub fn controller(&self) -> Option<&BrokerAddr>
pub fn controller(&self) -> Option<&BrokerAddr>
The controller, if one has been named and its address is known.
Sourcepub fn invalidate_controller(&mut self)
pub fn invalidate_controller(&mut self)
Forget which broker is the controller, after it said it is not.
Sourcepub fn invalidate_partition(&mut self, topic: &str, partition: i32)
pub fn invalidate_partition(&mut self, topic: &str, partition: i32)
Forget one partition’s leader, leaving the rest of the map alone.
Sourcepub fn partition_count(&self, topic: &str) -> i32
pub fn partition_count(&self, topic: &str) -> i32
How many partitions this topic has, or 0 if it has never been seen.
Taken from the last response that named the topic, so it is stable across elections: a partition without a leader still exists, and a count that dipped while one was being elected would silently move every key.
Sourcepub fn forget_topic(&mut self, topic: &str)
pub fn forget_topic(&mut self, topic: &str)
Forget a topic entirely — its count and every leader.
For a topic that was deleted. Deletion is the only way a partition count goes down, and it goes down by going away.
Sourcepub fn brokers(&self) -> impl Iterator<Item = &BrokerAddr>
pub fn brokers(&self) -> impl Iterator<Item = &BrokerAddr>
Every broker the client has heard of, for connection cleanup.