@classmethod
    def encode_produce_request(cls, payloads=(), acks=1, timeout=1000):
        """
        Encode a ProduceRequest struct

        Arguments:
            payloads: list of ProduceRequestPayload
            acks: How "acky" you want the request to be
                1: written to disk by the leader
                0: immediate response
                -1: waits for all replicas to be in sync
            timeout: Maximum time (in ms) the server will wait for replica acks.
                This is _not_ a socket timeout

        Returns: ProduceRequest
        """
        if acks not in (1, 0, -1):
            raise ValueError('ProduceRequest acks (%s) must be 1, 0, -1' % acks)

        return kafka.protocol.produce.ProduceRequest[0](
            required_acks=acks,
            timeout=timeout,
            topics=[(
                topic,
                [(
                    partition,
                    [(0, 0, kafka.protocol.message.Message(msg.value, key=msg.key,
                                                           magic=msg.magic,
                                                           attributes=msg.attributes))
                    for msg in payload.messages])
                for partition, payload in topic_payloads.items()])
            for topic, topic_payloads in group_by_topic_and_partition(payloads).items()])
dataset/ETHPy150Open dpkp/kafka-python/kafka/protocol/legacy.py/KafkaProtocol.encode_produce_request/original