kafka_ex v0.11.0 KafkaEx.New.ClusterMetadata View Source

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

Types

Possible errors given by select_node/2

t()

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

Find the node id for a given selector

Return the metadata for the given topics

Link to this section Types

Link to this type

node_select_error()

View Source
node_select_error() ::
  :no_such_node | :no_such_topic | :no_such_partition | :no_such_consumer_group

Possible errors given by select_node/2

Link to this type

t()

View Source
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

Link to this function

broker_by_node_id(cluster_metadata, node_id)

View Source

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

Link to this function

brokers(cluster_metadata)

View Source
brokers(t()) :: [KafkaEx.New.Broker.t()]

Return a list of the known brokers

Link to this function

from_metadata_v1_response(metadata)

View Source
from_metadata_v1_response(map()) :: t()

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.

Link to this function

known_topics(cluster_metadata)

View Source
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

Link to this function

select_node(cluster_metadata, node_selector)

View Source

Find the node id for a given selector

Note this will not update the metadata, only select a node given the current metadata.

See KafkaEx.New.NodeSelector.t/0

Link to this function

topics_metadata(cluster_metadata, wanted_topics)

View Source
topics_metadata(t(), [KafkaEx.New.KafkaExAPI.topic_name()]) :: [
  KafkaEx.New.Topic.t()
]

Return the metadata for the given topics