Skip to main content

Metadata

Struct Metadata 

Source
pub struct Metadata { /* private fields */ }
Expand description

What the client knows about the cluster.

Implementations§

Source§

impl Metadata

Source

pub fn new() -> Self

Source

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.

Source

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

Where to send a request for this partition, if known.

Source

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.

Source

pub fn controller(&self) -> Option<&BrokerAddr>

The controller, if one has been named and its address is known.

Source

pub fn invalidate_controller(&mut self)

Forget which broker is the controller, after it said it is not.

Source

pub fn invalidate_partition(&mut self, topic: &str, partition: i32)

Forget one partition’s leader, leaving the rest of the map alone.

Source

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.

Source

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.

Source

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

Every broker the client has heard of, for connection cleanup.

Source

pub fn is_empty(&self) -> bool

Trait Implementations§

Source§

impl Debug for Metadata

Source§

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

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

impl Default for Metadata

Source§

fn default() -> Metadata

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

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<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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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.