change_subscription called only when necessary (#1132)

When we are using subscription by pattern change subscription is
called every metadata update even when nothing changes. This PR
ensures that change subscription is called only when set of topics
changes.
This commit is contained in:
Petr Šebek
2017-07-07 21:29:40 +02:00
committed by Dana Powers
parent 71ce772484
commit 43939b29b5

View File

@@ -140,8 +140,9 @@ class ConsumerCoordinator(BaseCoordinator):
if self._subscription.subscribed_pattern.match(topic):
topics.append(topic)
self._subscription.change_subscription(topics)
self._client.set_topics(self._subscription.group_subscription())
if set(topics) != self._subscription.subscription:
self._subscription.change_subscription(topics)
self._client.set_topics(self._subscription.group_subscription())
# check if there are any changes to the metadata which should trigger
# a rebalance