Behaviours: gen_server.
This module defines the brod_topic_subscriber behaviour.
Required callback functions: init/2, handle_message/3.
Optional callback functions: terminate/2.
cb_fun() = fun((brod:partition(), brod:message() | brod:message_set(), cb_state()) -> cb_ret())
cb_ret() = {ok, cb_state()} | {ok, ack, cb_state()}
cb_state() = term()
committed_offsets() = [{brod:partition(), brod:offset()}]
topic_subscriber_config() = #{client := brod:client(), topic := brod:topic(), cb_module := module(), init_data => term(), message_type => message | message_set, consumer_config => brod:consumer_config(), partitions => all | [brod:partition()]}
ack/3 | Acknowledge that message has been sucessfully consumed. |
start_link/1 | Start (link) a topic subscriber which receives and processes the messages from a given partition set. |
start_link/6 | (Deprecated.) Equivalent to start_link(Client, Topic, Partitions, ConsumerConfig, message, CbModule, CbInitArg). |
start_link/7 | (Deprecated.) Start (link) a topic subscriber which receives and processes the messages or message sets from the given partition set. |
start_link/8 | (Deprecated.) Start (link) a topic subscriber which receives and processes the messages from the given partition set. |
stop/1 | Stop topic subscriber. |
ack(Pid::pid(), Partition::brod:partition(), Offset::brod:offset()) -> ok
Acknowledge that message has been sucessfully consumed.
start_link(Config::topic_subscriber_config()) -> {ok, pid()} | {error, term()}
Start (link) a topic subscriber which receives and processes the messages from a given partition set.
Possible Config
keys:
client
: Client ID (or pid, but not recommended) of the
brod client. Mandatorytopic
: Topic to consume from. Mandatorycb_module
: Callback module which should have the callback
functions implemented for message processing. Mandatoryconsumer_config
: For partition consumer, brod_topic_subscriber:start_link/6
. Optional, defaults to []
message_type
: The type of message that is going to be handled
by the callback module. Can be either message or message set.
Optional, defaults to message_set
init_data
: The term()
that is going to be passed to
CbModule:init/2
when initializing the subscriber. Optional,
defaults to undefined
partitions
: List of partitions to consume from, or atom
all
. Optional, defaults to all
.start_link(Client::brod:client(), Topic::brod:topic(), Partitions::all | [brod:partition()], ConsumerConfig::brod:consumer_config(), CbModule::module(), CbInitArg::term()) -> {ok, pid()} | {error, any()}
Equivalent to start_link(Client, Topic, Partitions, ConsumerConfig, message, CbModule, CbInitArg).
This function is deprecated: Please use start_link/1
instead
start_link(Client::brod:client(), Topic::brod:topic(), Partitions::all | [brod:partition()], ConsumerConfig::brod:consumer_config(), MessageType::message | message_set, CbModule::module(), CbInitArg::term()) -> {ok, pid()} | {error, any()}
This function is deprecated: Please use start_link/1
instead
Start (link) a topic subscriber which receives and processes the
messages or message sets from the given partition set. Use atom all
to subscribe to all partitions. Messages are handled by calling
CbModule:handle_message
start_link(Client::brod:client(), Topic::brod:topic(), Partitions::all | [brod:partition()], ConsumerConfig::brod:consumer_config(), CommittedOffsets::committed_offsets(), MessageType::message | message_set, CbFun::cb_fun(), CbInitialState::cb_state()) -> {ok, pid()} | {error, any()}
This function is deprecated: Please use start_link/1
instead
Start (link) a topic subscriber which receives and processes the
messages from the given partition set. Use atom all
to subscribe to all
partitions. Messages are handled by calling the callback function.
CommittedOffsets
are the offsets for the messages that have
been successfully processed (acknowledged), not the begin-offset
to start fetching from.
stop(Pid::pid()) -> ok
Stop topic subscriber.
Generated by EDoc