Esempio n. 1
0
 def _send_offset_fetch_request_either(self, group, payloads, fail_on_error,
                                       callback):
     return [
         callback(
             OffsetFetchResponsePayload(
                 req.topic, req.partition,
                 self.group_offsets[req.topic].get(req.partition,
                                                   -1), None, 0 if
                 req.partition in self.group_offsets[req.topic] else 3), )
         for req in payloads
     ]
Esempio n. 2
0
def pluck_topic_offset_or_zero_on_unknown(resp):
    try:
        check_error(resp)
    except UnknownTopicOrPartitionError:
        # If the server doesn't have any commited offsets by this group for
        # this topic, assume it's zero.
        pass
    # The API spec says server wont set an error, but 0.8.1.1 does. The actual
    # check is if the offset is -1.
    if resp.offset == -1:
        return OffsetFetchResponsePayload(
            resp.topic,
            resp.partition,
            0,
            resp.metadata,
            0,
        )
    return resp
Esempio n. 3
0
 def mock_offset_fetch_request(group, payloads, **kwargs):
     return [
         OffsetFetchResponsePayload(p.topic, p.partition, 0, b'', 0)
         for p in payloads
     ]