class HeadStruct(Struct): api_key = ShortField() api_version = ShortField(default=0) correlation_id = IntField() client_id_length = ShortField(default=len(KafkaProtocol.CLIENT_ID)) client_id = CharField(default=KafkaProtocol.CLIENT_ID, length='client_id_length')
class PartitionStruct(Struct): error = ShortField() partition = IntField() leader = IntField() replicas_number = IntField() replicas = IntField(repeat='replicas_number') isr_number = IntField() isr = IntField(repeat='isr_number')
class TopicStruct(Struct): error = ShortField() topic_name_length = ShortField() topic_name = CharField(length='topic_name_length') partitions_number = IntField() partitions = PartitionStruct(repeat='partitions_number')
class BrokerStruct(Struct): node_id = IntField() host_char_len = ShortField() host = CharField(length='host_char_len') port = IntField()
class MetaTopicStruct(Struct): topic_name_length = ShortField() topic_name = CharField(length='topic_name_length')
class ResponseTopicStruct(Struct): topic_name_length = ShortField() topic_name = CharField(length='topic_name_length') partitions_number = IntField() partitions = ResponsePartitionStruct(repeat='partitions_number')
class ResponsePartitionStruct(Struct): partition = IntField() error = ShortField() offset = LongLongField()
class ProduceStruct(Struct): head = HeadStruct(KafkaProtocol.PRODUCE_KEY, 0) acks = ShortField(default=1) timeout = IntField(default=1000) payloads_number = IntField() payloads = ProducePayloadStruct(repeat='payloads_number')
class ProducePayloadStruct(Struct): topic_name_length = ShortField() topic_name = CharField(length='topic_name_length') topic_payloads_number = IntField() topic_payloads = MessageSetStruct(repeat='topic_payloads_number')