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

ref: Add docstring about topic_name vs get_physical_topic_name. #3568

Merged
merged 1 commit into from
Jan 6, 2023
Merged
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
30 changes: 17 additions & 13 deletions snuba/datasets/table_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,23 @@ def topic(self) -> Topic:

@property
def topic_name(self) -> str:
return get_topic_name(self.__topic)
"""
Returns the physical topic name for the dataset. Ignores slicing.
Use ```get_physical_topic_name``` instead as it is slice aware.
"""
topic = self.__topic.value
return settings.KAFKA_TOPIC_MAP.get(topic, topic)

def get_physical_topic_name(self, slice_id: Optional[int] = None) -> str:
"""
Slice aware version of``topic_name``.
"""
if slice_id is not None:
physical_topic = SLICED_KAFKA_TOPIC_MAP[(self.topic_name, slice_id)]
else:
physical_topic = self.topic_name

return physical_topic

@property
def partitions_number(self) -> int:
Expand All @@ -59,18 +75,6 @@ def topic_creation_config(self) -> Mapping[str, str]:
def __eq__(self, other: object) -> bool:
return isinstance(other, KafkaTopicSpec) and self.topic == other.topic

def get_physical_topic_name(self, slice_id: Optional[int] = None) -> str:
if slice_id is not None:
physical_topic = SLICED_KAFKA_TOPIC_MAP[(self.topic_name, slice_id)]
else:
physical_topic = self.topic_name

return physical_topic


def get_topic_name(topic: Topic) -> str:
return settings.KAFKA_TOPIC_MAP.get(topic.value, topic.value)


class KafkaStreamLoader:
"""
Expand Down