View Source KafkaEx.New.KafkaExAPI (kafka_ex v0.13.0)

This module interfaces Kafka through the New.Client implementation

This is intended to become the future KafkaEx API

Most functions here take a client pid as the first argument.

{:ok, client} = KafkaEx.New.Client.start_link()

KafkaEx.New.KafkaExAPI.latest_offset(client, "some_topic", 0)

Link to this section Summary

Functions

Returns the cluster metadata from the given client

Returns the current correlation id for the given client

Fetch the latest offset for a given partition

Set the consumer group name that will be used by the given client for autocommit

Get topic metadata for the given topics

Link to this section Types

@type client() :: GenServer.server()
@type consumer_group_name() :: binary()
@type correlation_id() :: non_neg_integer()
@type error_atom() :: atom()
@type node_id() :: non_neg_integer()
@type offset() :: non_neg_integer()
@type partition_id() :: non_neg_integer()
@type topic_name() :: binary()

Link to this section Functions

Link to this function

cluster_metadata(client)

View Source
@spec cluster_metadata(client()) :: {:ok, KafkaEx.New.ClusterMetadata.t()}

Returns the cluster metadata from the given client

@spec correlation_id(client()) :: {:ok, correlation_id()}

Returns the current correlation id for the given client

Link to this function

latest_offset(client, topic, partition)

View Source
@spec latest_offset(client(), topic_name(), partition_id()) ::
  {:error, error_atom()} | {:ok, offset()}

Fetch the latest offset for a given partition

Link to this function

set_consumer_group_for_auto_commit(client, consumer_group)

View Source
@spec set_consumer_group_for_auto_commit(client(), consumer_group_name()) ::
  :ok | {:error, :invalid_consumer_group}

Set the consumer group name that will be used by the given client for autocommit

NOTE this function will not be supported after the legacy API is removed

Link to this function

topics_metadata(client, topics, allow_topic_creation \\ false)

View Source
@spec topics_metadata(client(), [topic_name()], boolean()) ::
  {:ok, [KafkaEx.New.Topic.t()]}

Get topic metadata for the given topics

Always calls out to the broker to get the most up-to-date metadata (and subsequently updates the client's state with the updated metadata). Set allow_topic_creation to true to allow the topics to be created if they don't exist