Skip to content

Commit

Permalink
Merge branch 'dont-retrieve-partition-data-on-apply' of github.com:re…
Browse files Browse the repository at this point in the history
…al-digital/esque into dont-retrieve-partition-data-on-apply
  • Loading branch information
hfjn committed Apr 15, 2021
2 parents 9fd8cf7 + cb3fd9f commit 3958177
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions esque/controller/topic_controller.py
Expand Up @@ -2,7 +2,6 @@
import re
import time
from contextlib import closing
from functools import partial
from itertools import islice
from logging import Logger
from typing import TYPE_CHECKING, Dict, List, Optional
Expand Down Expand Up @@ -48,10 +47,7 @@ def list_topics(
topic_names = sorted(topic_names)

if get_topic_objects:
if get_partitions:
topics = list(map(self.get_cluster_topic, topic_names))
else:
topics = list(map(partial(self.get_cluster_topic, retrieve_partition_data=False), topic_names))
topics = [self.get_cluster_topic(topic_name, retrieve_partition_data=False) for topic_name in topic_names]
else:
topics = list(map(self.get_local_topic, topic_names))
return topics
Expand Down Expand Up @@ -135,10 +131,7 @@ def update_from_cluster(
) -> Topic:
"""Takes a topic and, based on its name, updates all attributes from the cluster"""

if retrieve_partition_data:
topic.partition_data = self._get_partitions(topic, retrieve_last_timestamp)
else:
topic.partition_data = self._get_partitions(topic, retrieve_last_timestamp, get_partition_data=False)
topic.partition_data = self._get_partitions(topic, retrieve_last_timestamp, get_partition_data=retrieve_partition_data)
topic.config = self.cluster.retrieve_config(ConfigResource.Type.TOPIC, topic.name)

topic.is_only_local = False
Expand All @@ -159,7 +152,7 @@ def _get_partitions(
partitions: List[Partition] = []
if not get_partition_data:
return [
Partition(partition_id, 0, 0, meta.isrs, meta.leader, meta.replicas, None)
Partition(partition_id, -1, -1, meta.isrs, meta.leader, meta.replicas, None)
for partition_id, meta in confluent_topic.partitions.items()
]
for partition_id, meta in confluent_topic.partitions.items():
Expand Down

0 comments on commit 3958177

Please sign in to comment.