Module brod_topic_subscriber

A topic subscriber is a gen_server which subscribes to all or a given set of partition consumers (pollers) of a given topic and calls the user-defined callback functions for message processing.

Behaviours: gen_server.

This module defines the brod_topic_subscriber behaviour.
Required callback functions: init/2, handle_message/3.
Optional callback functions: terminate/2.

Description

A topic subscriber is a gen_server which subscribes to all or a given set of partition consumers (pollers) of a given topic and calls the user-defined callback functions for message processing.

Data Types

cb_fun()

cb_fun() = fun((brod:partition(), brod:message() | brod:message_set(), cb_state()) -> cb_ret())

cb_ret()

cb_ret() = {ok, cb_state()} | {ok, ack, cb_state()}

cb_state()

cb_state() = term()

committed_offsets()

committed_offsets() = [{brod:partition(), brod:offset()}]

topic_subscriber_config()

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()]}

Function Index

ack/3Acknowledge that message has been sucessfully consumed.
start_link/1Start (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/1Stop topic subscriber.

Function Details

ack/3

ack(Pid::pid(), Partition::brod:partition(), Offset::brod:offset()) -> ok

Acknowledge that message has been sucessfully consumed.

start_link/1

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:

start_link/6

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/7

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/8

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.

NOTE: CommittedOffsets are the offsets for the messages that have been successfully processed (acknowledged), not the begin-offset to start fetching from.

stop/1

stop(Pid::pid()) -> ok

Stop topic subscriber.


Generated by EDoc