def _verify_source_topic_partitions(self, source_topic: str) -> None: # This was formerly wrapped in an lru_cache. The linter sees issues with this # as an instance stays cached. # This is why we implement a non lru_cached lookup which checks if the # function has already been executed once on the instance level. if source_topic in self._verified_source_topics_for_partitions: return change_topic = self.changelog_topic_name source_n = self.app.consumer.topic_partitions(source_topic) if source_n is not None: change_n = self.app.consumer.topic_partitions(change_topic) if change_n is not None: if source_n != change_n: raise PartitionsMismatch( E_SOURCE_PARTITIONS_MISMATCH.format( source_topic=source_topic, table_name=self.name, source_n=source_n, change_topic=change_topic, change_n=change_n, ), ) self._verified_source_topics_for_partitions.add(source_topic)
def _verify_source_topic_partitions(self, source_topic: str) -> None: change_topic = self.changelog_topic_name source_n = self.app.consumer.topic_partitions(source_topic) if source_n is not None: change_n = self.app.consumer.topic_partitions(change_topic) if change_n is not None: if source_n != change_n: raise PartitionsMismatch( E_SOURCE_PARTITIONS_MISMATCH.format( source_topic=source_topic, table_name=self.name, source_n=source_n, change_topic=change_topic, change_n=change_n, ), )