Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify cluster metadata #942

Closed
wants to merge 3 commits into from
Closed
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
9 changes: 6 additions & 3 deletions aiokafka/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
def __init__(self, **configs):
self._brokers = {} # node_id -> BrokerMetadata
self._partitions = {} # topic -> partition -> PartitionMetadata
self._topics = set()
# node_id -> {TopicPartition...}
self._broker_partitions = collections.defaultdict(set)
self._groups = {} # group_name -> node_id
Expand All @@ -55,6 +56,7 @@
self.need_all_topic_metadata = False
self.unauthorized_topics = set()
self.internal_topics = set()
self.external_topics = set()
self.controller = None

self.config = copy.copy(self.DEFAULT_CONFIG)
Expand Down Expand Up @@ -191,11 +193,10 @@
Returns:
set: {topic (str), ...}
"""
topics = set(self._partitions.keys())
if exclude_internal_topics:
return topics - self.internal_topics
return self.external_topics

Check warning on line 197 in aiokafka/cluster.py

View check run for this annotation

Codecov / codecov/patch

aiokafka/cluster.py#L197

Added line #L197 was not covered by tests
else:
return topics
return self._topics

Check warning on line 199 in aiokafka/cluster.py

View check run for this annotation

Codecov / codecov/patch

aiokafka/cluster.py#L199

Added line #L199 was not covered by tests

def failed_update(self, exception):
"""Update cluster state given a failed MetadataRequest."""
Expand Down Expand Up @@ -282,9 +283,11 @@
self._brokers = _new_brokers
self.controller = _new_controller
self._partitions = _new_partitions
self._topics = set(self._partitions.keys())
self._broker_partitions = _new_broker_partitions
self.unauthorized_topics = _new_unauthorized_topics
self.internal_topics = _new_internal_topics
self.external_topics = self._topics - self.internal_topics
f = None
if self._future:
f = self._future
Expand Down
Loading