View Source KafkaEx.New.ClusterMetadata (kafka_ex v0.13.0)
Encapsulates what we know about the state of a Kafka broker cluster
This module is mainly used internally in New.Client, but some of its functions may be useful for extracting metadata information
Link to this section Summary
Functions
Returns a t:Broker.t/0
for the given t:KafkaExAPI.node_id/0
or nil
if
there is no known broker with that node id
Return a list of the known brokers
Constructs a t/0
from a Kayrock.Metadata.V1.Response
struct.
List names of topics known by the cluster metadata
Find the node id for a given selector
Return the metadata for the given topics
Link to this section Types
@type node_select_error() ::
:no_such_node | :no_such_topic | :no_such_partition | :no_such_consumer_group
Possible errors given by select_node/2
@type t() :: %KafkaEx.New.ClusterMetadata{ brokers: %{ required(KafkaEx.New.KafkaExAPI.node_id()) => KafkaEx.New.Broker.t() }, consumer_group_coordinators: %{ required(KafkaEx.New.KafkaExAPI.consumer_group_name()) => KafkaEx.New.KafkaExAPI.node_id() }, controller_id: KafkaEx.New.KafkaExAPI.node_id(), topics: %{ required(KafkaEx.New.KafkaExAPI.topic_name()) => KafkaEx.New.Topic.t() } }
Link to this section Functions
@spec broker_by_node_id(t(), KafkaEx.New.KafkaExAPI.node_id()) :: KafkaEx.New.Broker.t()
Returns a t:Broker.t/0
for the given t:KafkaExAPI.node_id/0
or nil
if
there is no known broker with that node id
@spec brokers(t()) :: [KafkaEx.New.Broker.t()]
Return a list of the known brokers
Constructs a t/0
from a Kayrock.Metadata.V1.Response
struct.
The V1
here is a minimum - this should work with higher versions of the
metadata response struct.
@spec known_topics(t()) :: [KafkaEx.New.KafkaExAPI.topic_name()]
List names of topics known by the cluster metadata
NOTE this is a subset of the topics in the cluster - it will only contain topics for which we have fetched metadata
@spec select_node(t(), KafkaEx.New.NodeSelector.t()) :: {:ok, KafkaEx.New.KafkaExAPI.node_id()} | {:error, node_select_error()}
Find the node id for a given selector
Note this will not update the metadata, only select a node given the current metadata.
@spec topics_metadata(t(), [KafkaEx.New.KafkaExAPI.topic_name()]) :: [ KafkaEx.New.Topic.t() ]
Return the metadata for the given topics