improve documentation of tuple GenConsumer arguments
MODIFY
lib/kafka_ex/consumer_group.ex
lib/kafka_ex/consumer_group.ex
@@ -120,11 +120,20 @@ defmodule KafkaEx.ConsumerGroup do
This can be used to start a `KafkaEx.ConsumerGroup` as part of a supervision
tree.
- `module` is a module that implements the `KafkaEx.GenConsumer` behaviour.
- `group_name` is the name of the consumer group. `topics` is a list of topics
- that the consumer group should consume from. `opts` can be composed of
- options for the supervisor as well as for the `KafkEx.GenConsumer` processes
- that will be spawned by the supervisor. See `t:option/0` for details.
+ `consumer_module` is
+ - a module that implements the `KafkaEx.GenConsumer`
+ behaviour.
+ - a tuple of `{gen_consumer_module, consumer_module}` can substitute another
+ `GenServer` implementation for `KafkaEx.GenConsumer`. When a single module
+ is passed it is transformed to `{KafkaEx.GenConsumer, consumer_module}`.
+
+ `group_name` is the name of the consumer group.
+
+ `topics` is a list of topics that the consumer group should consume from.
+
+ `opts` can be composed of options for the supervisor as well as for the
+ `KafkEx.GenConsumer` processes that will be spawned by the supervisor. See
+ `t:option/0` for details.
*Note* When starting a consumer group with multiple topics, you should
propagate this configuration change to your consumers. If you add a topic to
@@ -135,21 +144,15 @@ defmodule KafkaEx.ConsumerGroup do
This function has the same return values as `Supervisor.start_link/3`.
"""
- @spec start_link(module | {module, module}, binary, [binary], options) :: Supervisor.on_start()
+ @spec start_link(module | {module, module}, binary, [binary], options) ::
+ Supervisor.on_start()
def start_link(consumer_module, group_name, topics, opts \\ [])
+
def start_link(consumer_module, group_name, topics, opts)
when is_atom(consumer_module) do
start_link({KafkaEx.GenConsumer, consumer_module}, group_name, topics, opts)
end
- @doc """
- Starts a consumer group process tree with an alternate consumer implementation.
-
- By default starts `KafkaEx.GenConsumer` But can be passed any module
- implementing `GenServer`. The consumer is responsible for pulling messages and
- managing its commit state. For example `KafkExGenStageConsumer` implements a
- `GenStage` producer which pulls messages from kafka according to demand.
- """
def start_link(
{gen_consumer_module, consumer_module},
group_name,

MODIFY
lib/kafka_ex/gen_consumer.ex
lib/kafka_ex/gen_consumer.ex
@@ -439,7 +439,7 @@ defmodule KafkaEx.GenConsumer do
This function has the same return values as `GenServer.start_link/3`.
"""
@spec start_link(
- callback_module :: module,
+ consumer_module :: module,
consumer_group_name :: binary,
topic_name :: binary,
partition_id :: non_neg_integer,

MODIFY
lib/kafka_ex/gen_consumer/supervisor.ex
lib/kafka_ex/gen_consumer/supervisor.ex
@@ -18,7 +18,9 @@ defmodule KafkaEx.GenConsumer.Supervisor do
@doc """
Starts a `GenConsumer.Supervisor` process linked to the current process.
- `module` is a module that implements the `GenConsumer` behaviour.
+ `gen_consumer_module` is a module that implements the `GenServer` behaviour
+ which consumes events from kafka.
+ `consumer_module` is a module that implements the `GenConsumer` behaviour.
`group_name` is the name of a consumer group, and `assignments` is a list of
partitions for the `GenConsumer`s to consume. `opts` accepts the same
options as `KafkaEx.GenConsumer.start_link/5`.
@@ -31,7 +33,8 @@ defmodule KafkaEx.GenConsumer.Supervisor do
returns `{:ok, pid}`, where `pid` is the PID of the supervisor.
"""
@spec start_link(
- {callback_module :: module, consumer_group_name :: binary},
+ {gen_consumer_module ::module, consumer_module :: module},
+ consumer_group_name :: binary,
assigned_partitions :: [
{topic_name :: binary, partition_id :: non_neg_integer}
],

improve documentation of tuple GenConsumer arguments