async def commit(self, tps: Mapping[TP, int]) -> bool: self.call_thread( self._ensure_consumer().commit, offsets=[ _TopicPartition(tp.topic, tp.partition, offset=offset) for tp, offset in tps.items() ], asynchronous=False, ) return True
def highwater(self, tp: TP) -> int: _, hw = self._ensure_consumer().get_watermark_offsets(_TopicPartition( tp.topic, tp.partition), cached=True) return hw
async def _committed_offsets( self, partitions: List[TP]) -> MutableMapping[TP, int]: consumer = self._ensure_consumer() committed = consumer.committed( [_TopicPartition(tp[0], tp[1]) for tp in partitions]) return {TP(tp.topic, tp.partition): tp.offset for tp in committed}
def _new_topicpartition(self, topic: str, partition: int) -> TP: return cast(TP, _TopicPartition(topic, partition))