Skip to content
This repository has been archived by the owner on May 13, 2019. It is now read-only.

check whether comsumer subscript the topic or not when divide partiti… #131

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
13 changes: 12 additions & 1 deletion consumergroup/consumer_group.go
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,18 @@ func (cg *ConsumerGroup) topicConsumer(topic string, messages chan<- *sarama.Con
return
}

dividedPartitions := dividePartitionsBetweenConsumers(cg.consumers, partitionLeaders)
topicConsumers := []*kazoo.ConsumergroupInstance{}
for _, consumer := range cg.consumers{
reg, _ := consumer.Registration()
for sub, _ := range reg.Subscription{
if sub == topic{
topicConsumers = append(topicConsumers, consumer)
break
}
}
}

dividedPartitions := dividePartitionsBetweenConsumers(topicConsumers, partitionLeaders)
myPartitions := dividedPartitions[cg.instance.ID]
cg.Logf("%s :: Claiming %d of %d partitions", topic, len(myPartitions), len(partitionLeaders))

Expand Down