View Source KafkaEx.New.KafkaExAPI (kafka_ex v0.15.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)
Summary
Functions
Returns the cluster metadata from the given client
Returns the current correlation id for the given client
Sends a request to describe a group identified by its name. We support only one consumer group per request for now, as we don't group requests by group coordinator.
Fetch the latest offset for a given partition
Fetch the latest offset for a given partition
Returns list of Offsets per topic per partition. We support only one topic partition pair for now, as we don't request by leader.
Set the consumer group name that will be used by the given client for autocommit
Get topic metadata for the given topics
Types
@type client() :: GenServer.server()
@type consumer_group_name() :: KafkaEx.Types.consumer_group_name()
@type correlation_id() :: non_neg_integer()
@type error_atom() :: atom()
@type node_id() :: non_neg_integer()
@type offset_val() :: KafkaEx.Types.offset()
@type opts() :: Keyword.t()
@type partition_id() :: KafkaEx.Types.partition()
@type partition_offset_request() :: %{ partition_num: partition_id(), timestamp: timestamp_request() }
@type timestamp_request() :: KafkaEx.Types.timestamp_request()
@type topic_name() :: KafkaEx.Types.topic()
Functions
@spec cluster_metadata(client()) :: {:ok, KafkaEx.New.Structs.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
@spec describe_group(client(), consumer_group_name(), opts()) :: {:ok, KafkaEx.New.Structs.ConsumerGroup.t()} | {:error, any()}
Sends a request to describe a group identified by its name. We support only one consumer group per request for now, as we don't group requests by group coordinator.
@spec earliest_offset(client(), topic_name(), partition_id(), opts()) :: {:error, error_atom()} | {:ok, offset_val()}
Fetch the latest offset for a given partition
@spec latest_offset(client(), topic_name(), partition_id(), opts()) :: {:error, error_atom()} | {:ok, offset_val()}
Fetch the latest offset for a given partition
@spec list_offsets(client(), [{topic_name(), [partition_offset_request()]}], opts()) :: {:ok, [KafkaEx.New.Structs.Offset.t()]} | {:error, any()}
Returns list of Offsets per topic per partition. We support only one topic partition pair for now, as we don't request by leader.
@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
@spec topics_metadata(client(), [topic_name()], boolean()) :: {:ok, [KafkaEx.New.Structs.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