Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/kafka_ex/consumer_group.ex
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,14 @@ defmodule KafkaEx.ConsumerGroup do
|> GenConsumer.Supervisor.child_pids
end

@doc """
Returns the name of the consumer group
"""
@spec group_name(Supervisor.supervisor) :: binary
def group_name(supervisor_pid) do
call_manager(supervisor_pid, :group_name)
end

@doc """
Returns a map from `{topic, partition_id}` to consumer pid
"""
Expand Down
4 changes: 4 additions & 0 deletions lib/kafka_ex/consumer_group/manager.ex
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ defmodule KafkaEx.ConsumerGroup.Manager do
def handle_call(:consumer_supervisor_pid, _from, state) do
{:reply, state.consumer_supervisor_pid, state}
end

def handle_call(:group_name, _from, state) do
{:reply, state.group_name, state}
end
######################################################################

# If `member_id` and `generation_id` aren't set, we haven't yet joined the
Expand Down
3 changes: 3 additions & 0 deletions test/integration/consumer_group_implementation_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ defmodule KafkaEx.ConsumerGroupImplementationTest do
generation_id2 = ConsumerGroup.generation_id(context[:consumer_group_pid2])
assert generation_id1 == generation_id2

assert @consumer_group_name ==
ConsumerGroup.group_name(context[:consumer_group_pid1])

member1 = ConsumerGroup.member_id(context[:consumer_group_pid1])
member2 = ConsumerGroup.member_id(context[:consumer_group_pid2])
assert member1 != member2
Expand Down