Exemplo n.º 1
0
 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
Exemplo n.º 2
0
 def highwater(self, tp: TP) -> int:
     _, hw = self._ensure_consumer().get_watermark_offsets(_TopicPartition(
         tp.topic, tp.partition),
                                                           cached=True)
     return hw
Exemplo n.º 3
0
 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}
Exemplo n.º 4
0
 def _new_topicpartition(self, topic: str, partition: int) -> TP:
     return cast(TP, _TopicPartition(topic, partition))