@classmethod<EOL><INDENT>def encode_fetch_request(cls, client_id, correlation_id, payloads=None,<EOL>max_wait_time=<NUM_LIT:100>, min_bytes=<NUM_LIT>):<DEDENT>
payloads = [] if payloads is None else payloads<EOL>grouped_payloads = group_by_topic_and_partition(payloads)<EOL>message = []<EOL>message.append(cls._encode_message_header(client_id, correlation_id,<EOL>KafkaProtocol.FETCH_KEY))<EOL>message.append(struct.pack('<STR_LIT>', -<NUM_LIT:1>, max_wait_time, min_bytes,<EOL>len(grouped_payloads)))<EOL>for topic, topic_payloads in grouped_payloads.items():<EOL><INDENT>message.append(write_short_string(topic))<EOL>message.append(struct.pack('<STR_LIT>', len(topic_payloads)))<EOL>for partition, payload in topic_payloads.items():<EOL><INDENT>message.append(struct.pack('<STR_LIT>', partition, payload.offset,<EOL>payload.max_bytes))<EOL><DEDENT><DEDENT>msg = b'<STR_LIT>'.join(message)<EOL>return struct.pack('<STR_LIT>' % len(msg), len(msg), msg)<EOL>
Encodes some FetchRequest structs

Arguments:
    client_id: string
    correlation_id: int
    payloads: list of FetchRequest
    max_wait_time: int, how long to block waiting on min_bytes of data
    min_bytes: int, the minimum number of bytes to accumulate before
               returning the response