def _check_commit_response_error(resp): try: check_error(resp) except BrokerResponseError as e: exception = OffsetCommitError(resp.topic, resp.partition, e.message) return exception return resp
def _check_fetch_response_error(resp): try: check_error(resp) except BrokerResponseError: # In case of error we set the offset to (-1,) return OffsetResponsePayload( resp.topic, resp.partition, resp.error, (-1, ), ) return resp
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