View Source brod_client (brod v3.16.3)
Link to this section Summary
Functions
De-register the consumer for a partition. The partition consumer entry is deleted from the ETS table to allow cleanup of purposefully stopped consumers and allow later restart.
De-register the producer for a partition. The partition producer entry is deleted from the ETS table to allow cleanup of purposefully stopped producers and allow later restart.
Get connection to a kafka broker. Return already established connection towards the broker, otherwise a new one is established and cached in client state. If the old connection was dead less than a configurable N seconds ago,
{error, LastReason}
is returned.Get consumer of the given topic-parition.
Get broker endpoint and connection config for connecting a group coordinator.
Get the connection to kafka broker which is a leader for given Topic-Partition. Return already established connection towards the leader broker, Otherwise a new one is established and cached in client state. If the old connection was dead less than a configurable N seconds ago,
{error, LastReason}
is returned.Get topic metadata, if topic is
undefined
, will fetch ALL metadata.Get number of partitions for a given topic.
Get producer of the given topic-partition. The producer is started if auto_start_producers is enabled in client config.
Register self() as a partition consumer. The pid is registered in an ETS table, then the callers may lookup a consumer pid from the table and make subscribe calls to the process directly.
Register self() as a partition producer. The pid is registered in an ETS table, then the callers may lookup a producer pid from the table and make produce requests to the producer process directly.
Dynamically start a topic consumer. Returns ok if the consumer is already started.
Dynamically start a per-topic producer. Return ok if the producer is already started.
Stop all partition consumers of the given topic.
Stop all partition producers of the given topic.
Link to this section Types
-type client() :: brod:client().
-type client_id() :: brod:client_id().
-type config() :: proplists:proplist().
-type conn_state() :: #conn{}.
-type connection() :: kpro:connection().
-type dead_conn() :: {dead_since, erlang:timestamp(), any()}.
-type endpoint() :: brod:endpoint().
-type get_worker_error() :: get_producer_error() | get_consumer_error().
-type group_id() :: brod:group_id().
-type partition() :: brod:partition().
-type state() :: #state{}.
-type topic() :: brod:topic().
Link to this section Functions
-spec find_consumer(client(), topic(), partition()) -> {ok, pid()} | {error, get_consumer_error()}.
-spec find_producer(client(), topic(), partition()) -> {ok, pid()} | {error, get_producer_error()}.
-spec get_connection(client(), brod:hostname(), brod:portnum()) -> {ok, pid()} | {error, any()}.
{error, LastReason}
is returned.
-spec get_consumer(client(), topic(), partition()) -> {ok, pid()} | {error, get_consumer_error()}.
-spec get_group_coordinator(client(), group_id()) -> {ok, {endpoint(), brod:conn_config()}} | {error, any()}.
{error, LastReason}
is returned.
-spec get_metadata(client(), all | undefined | topic()) -> {ok, kpro:struct()} | {error, any()}.
undefined
, will fetch ALL metadata.
-spec get_producer(client(), topic(), partition()) -> {ok, pid()} | {error, get_producer_error()}.
-spec start_consumer(client(), topic(), brod:consumer_config()) -> ok | {error, any()}.
-spec start_producer(client(), topic(), brod:producer_config()) -> ok | {error, any()}.
-spec stop(client()) -> ok.