View Source KafkaEx.Cluster.ClusterMetadata (kafka_ex v1.0.0-rc.1)
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
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
List names of topics known by the cluster metadata
Merge two sets of cluster metadata with their brokers. Returns the merged metadata and a list of brokers that should have their connections closed because they are not present in the new metadata
update a consumer group coordinator node id
remove the given topics (e.g., when they are deleted)
Find the node id for a given selector
Return the metadata for the given topics
Execute an update callback on each broker
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.Cluster.ClusterMetadata{ brokers: %{required(KafkaEx.API.node_id()) => KafkaEx.Cluster.Broker.t()}, consumer_group_coordinators: %{ required(KafkaEx.API.consumer_group_name()) => KafkaEx.API.node_id() }, controller_id: KafkaEx.API.node_id() | nil, topics: %{required(KafkaEx.API.topic_name()) => KafkaEx.Cluster.Topic.t()} }
Functions
@spec broker_by_node_id(t(), KafkaEx.API.node_id()) :: KafkaEx.Cluster.Broker.t() | nil
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.Cluster.Broker.t()]
Return a list of the known brokers
@spec known_topics(t()) :: [KafkaEx.API.topic_name()]
List names of topics known by the cluster metadata
Tthis is a subset of the topics in the cluster - it will only contain topics for which we have fetched metadata
@spec merge_brokers(t(), t()) :: {t(), [KafkaEx.Cluster.Broker.t()]}
Merge two sets of cluster metadata with their brokers. Returns the merged metadata and a list of brokers that should have their connections closed because they are not present in the new metadata
put_consumer_group_coordinator(cluster_metadata, consumer_group, coordinator_node_id)
View Source@spec put_consumer_group_coordinator( t(), KafkaEx.API.consumer_group_name(), KafkaEx.API.node_id() ) :: t()
update a consumer group coordinator node id
@spec remove_topics(t(), [KafkaEx.API.topic_name()]) :: t()
remove the given topics (e.g., when they are deleted)
@spec select_node(t(), KafkaEx.Client.NodeSelector.t()) :: {:ok, KafkaEx.API.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.API.topic_name()]) :: [KafkaEx.Cluster.Topic.t()]
Return the metadata for the given topics
@spec update_brokers(t(), (KafkaEx.Cluster.Broker.t() -> KafkaEx.Cluster.Broker.t())) :: t()
Execute an update callback on each broker