예제 #1
0
class CreatePartitionsResponse_v0(Response):
    API_KEY = 37
    API_VERSION = 0
    SCHEMA = Schema(('throttle_time_ms', Int32),
                    ('topic_errors',
                     Array(('topic', String('utf-8')), ('error_code', Int16),
                           ('error_message', String('utf-8')))))
예제 #2
0
class CreateTopicsResponse_v2(Response):
    API_KEY = 19
    API_VERSION = 2
    SCHEMA = Schema(('throttle_time_ms', Int32),
                    ('topic_error_codes',
                     Array(('topic', String('utf-8')), ('error_code', Int16),
                           ('error_message', String('utf-8')))))
예제 #3
0
class ListGroupsResponse_v1(Response):
    API_KEY = 16
    API_VERSION = 1
    SCHEMA = Schema(('throttle_time_ms', Int32), ('error_code', Int16),
                    ('groups',
                     Array(('group', String('utf-8')),
                           ('protocol_type', String('utf-8')))))
예제 #4
0
class ListGroupsResponse_v0(Response):
    API_KEY = 16
    API_VERSION = 0
    SCHEMA = Schema(('error_code', Int16),
                    ('groups',
                     Array(('group', String('utf-8')),
                           ('protocol_type', String('utf-8')))))
예제 #5
0
class OffsetFetchRequest_v0(Request):
    API_KEY = 9
    API_VERSION = 0  # zookeeper-backed storage
    RESPONSE_TYPE = OffsetFetchResponse_v0
    SCHEMA = Schema(('consumer_group', String('utf-8')),
                    ('topics',
                     Array(('topic', String('utf-8')),
                           ('partitions', Array(Int32)))))
예제 #6
0
class OffsetFetchResponse_v0(Response):
    API_KEY = 9
    API_VERSION = 0
    SCHEMA = Schema(
        ('topics',
         Array(('topic', String('utf-8')),
               ('partitions',
                Array(('partition', Int32), ('offset', Int64),
                      ('metadata', String('utf-8')), ('error_code', Int16))))))
예제 #7
0
class JoinGroupResponse_v0(Response):
    API_KEY = 11
    API_VERSION = 0
    SCHEMA = Schema(
        ('error_code', Int16), ('generation_id', Int32),
        ('group_protocol', String('utf-8')), ('leader_id', String('utf-8')),
        ('member_id', String('utf-8')), ('members',
                                         Array(('member_id', String('utf-8')),
                                               ('member_metadata', Bytes))))
예제 #8
0
class SyncGroupRequest_v0(Request):
    API_KEY = 14
    API_VERSION = 0
    RESPONSE_TYPE = SyncGroupResponse_v0
    SCHEMA = Schema(('group', String('utf-8')), ('generation_id', Int32),
                    ('member_id', String('utf-8')),
                    ('group_assignment',
                     Array(('member_id', String('utf-8')),
                           ('member_metadata', Bytes))))
예제 #9
0
class ProduceRequest_v3(ProduceRequest):
    API_VERSION = 3
    RESPONSE_TYPE = ProduceResponse_v3
    SCHEMA = Schema(
        ('transactional_id', String('utf-8')), ('required_acks', Int16),
        ('timeout', Int32),
        ('topics',
         Array(('topic', String('utf-8')),
               ('partitions', Array(('partition', Int32),
                                    ('messages', Bytes))))))
예제 #10
0
class OffsetCommitRequest_v0(Request):
    API_KEY = 8
    API_VERSION = 0  # Zookeeper-backed storage
    RESPONSE_TYPE = OffsetCommitResponse_v0
    SCHEMA = Schema(('consumer_group', String('utf-8')),
                    ('topics',
                     Array(('topic', String('utf-8')),
                           ('partitions',
                            Array(('partition', Int32), ('offset', Int64),
                                  ('metadata', String('utf-8')))))))
예제 #11
0
class JoinGroupRequest_v0(Request):
    API_KEY = 11
    API_VERSION = 0
    RESPONSE_TYPE = JoinGroupResponse_v0
    SCHEMA = Schema(('group', String('utf-8')), ('session_timeout', Int32),
                    ('member_id', String('utf-8')),
                    ('protocol_type', String('utf-8')),
                    ('group_protocols',
                     Array(('protocol_name', String('utf-8')),
                           ('protocol_metadata', Bytes))))
    UNKNOWN_MEMBER_ID = ''
예제 #12
0
class OffsetCommitRequest_v1(Request):
    API_KEY = 8
    API_VERSION = 1  # Kafka-backed storage
    RESPONSE_TYPE = OffsetCommitResponse_v1
    SCHEMA = Schema(('consumer_group', String('utf-8')),
                    ('consumer_group_generation_id', Int32),
                    ('consumer_id', String('utf-8')),
                    ('topics',
                     Array(('topic', String('utf-8')),
                           ('partitions',
                            Array(('partition', Int32), ('offset', Int64),
                                  ('timestamp', Int64),
                                  ('metadata', String('utf-8')))))))
예제 #13
0
class CreateTopicsRequest_v1(Request):
    API_KEY = 19
    API_VERSION = 1
    RESPONSE_TYPE = CreateTopicsResponse_v1
    SCHEMA = Schema(
        ('create_topic_requests',
         Array(('topic', String('utf-8')), ('num_partitions', Int32),
               ('replication_factor', Int16),
               ('replica_assignment',
                Array(('partition_id', Int32), ('replicas', Array(Int32)))),
               ('configs',
                Array(('config_key', String('utf-8')),
                      ('config_value', String('utf-8')))))),
        ('timeout', Int32), ('validate_only', Boolean))
예제 #14
0
class OffsetCommitRequest_v2(Request):
    API_KEY = 8
    API_VERSION = 2  # added retention_time, dropped timestamp
    RESPONSE_TYPE = OffsetCommitResponse_v2
    SCHEMA = Schema(('consumer_group', String('utf-8')),
                    ('consumer_group_generation_id', Int32),
                    ('consumer_id', String('utf-8')),
                    ('retention_time', Int64),
                    ('topics',
                     Array(('topic', String('utf-8')),
                           ('partitions',
                            Array(('partition', Int32), ('offset', Int64),
                                  ('metadata', String('utf-8')))))))
    DEFAULT_GENERATION_ID = -1
    DEFAULT_RETENTION_TIME = -1
예제 #15
0
class ProduceResponse_v0(Response):
    API_KEY = 0
    API_VERSION = 0
    SCHEMA = Schema(('topics',
                     Array(('topic', String('utf-8')),
                           ('partitions',
                            Array(('partition', Int32), ('error_code', Int16),
                                  ('offset', Int64))))))
예제 #16
0
class RequestHeader(Struct):
    SCHEMA = Schema(('api_key', Int16), ('api_version', Int16),
                    ('correlation_id', Int32), ('client_id', String('utf-8')))

    def __init__(self, request, correlation_id=0, client_id='kafka-python'):
        super(RequestHeader,
              self).__init__(request.API_KEY, request.API_VERSION,
                             correlation_id, client_id)
예제 #17
0
class MetadataRequest_v0(Request):
    API_KEY = 3
    API_VERSION = 0
    RESPONSE_TYPE = MetadataResponse_v0
    SCHEMA = Schema(
        ('topics', Array(String('utf-8')))
    )
    ALL_TOPICS = None  # Empty Array (len 0) for topics returns all topics
예제 #18
0
class OffsetResponse_v1(Response):
    API_KEY = 2
    API_VERSION = 1
    SCHEMA = Schema(('topics',
                     Array(('topic', String('utf-8')),
                           ('partitions',
                            Array(('partition', Int32), ('error_code', Int16),
                                  ('timestamp', Int64), ('offset', Int64))))))
예제 #19
0
class OffsetCommitResponse_v0(Response):
    API_KEY = 8
    API_VERSION = 0
    SCHEMA = Schema(
        ('topics',
         Array(('topic', String('utf-8')),
               ('partitions', Array(('partition', Int32),
                                    ('error_code', Int16))))))
예제 #20
0
class FetchResponse_v0(Response):
    API_KEY = 1
    API_VERSION = 0
    SCHEMA = Schema(
        ('topics',
         Array(('topics', String('utf-8')),
               ('partitions',
                Array(('partition', Int32), ('error_code', Int16),
                      ('highwater_offset', Int64), ('message_set', Bytes))))))
예제 #21
0
class MetadataResponse_v0(Response):
    API_KEY = 3
    API_VERSION = 0
    SCHEMA = Schema(
        ('brokers', Array(
            ('node_id', Int32),
            ('host', String('utf-8')),
            ('port', Int32))),
        ('topics', Array(
            ('error_code', Int16),
            ('topic', String('utf-8')),
            ('partitions', Array(
                ('error_code', Int16),
                ('partition', Int32),
                ('leader', Int32),
                ('replicas', Array(Int32)),
                ('isr', Array(Int32))))))
    )
예제 #22
0
class ProduceResponse_v2(Response):
    API_KEY = 0
    API_VERSION = 2
    SCHEMA = Schema(('topics',
                     Array(('topic', String('utf-8')),
                           ('partitions',
                            Array(('partition', Int32), ('error_code', Int16),
                                  ('offset', Int64), ('timestamp', Int64))))),
                    ('throttle_time_ms', Int32))
예제 #23
0
class MetadataRequest_v4(Request):
    API_KEY = 3
    API_VERSION = 4
    RESPONSE_TYPE = MetadataResponse_v4
    SCHEMA = Schema(
        ('topics', Array(String('utf-8'))),
        ('allow_auto_topic_creation', Boolean)
    )
    ALL_TOPICS = -1  # Null Array (len -1) for topics returns all topics
    NO_TOPICS = None  # Empty array (len 0) for topics returns no topics
예제 #24
0
class CreatePartitionsRequest_v0(Request):
    API_KEY = 37
    API_VERSION = 0
    RESPONSE_TYPE = CreatePartitionsResponse_v0
    SCHEMA = Schema(('topic_partitions',
                     Array(('topic', String('utf-8')),
                           ('new_partitions',
                            Schema(('count', Int32),
                                   ('assignment', Array(Int32)))))),
                    ('timeout', Int32), ('validate_only', Boolean))
예제 #25
0
class FetchRequest_v0(Request):
    API_KEY = 1
    API_VERSION = 0
    RESPONSE_TYPE = FetchResponse_v0
    SCHEMA = Schema(('replica_id', Int32), ('max_wait_time', Int32),
                    ('min_bytes', Int32),
                    ('topics',
                     Array(('topic', String('utf-8')),
                           ('partitions',
                            Array(('partition', Int32), ('offset', Int64),
                                  ('max_bytes', Int32))))))
예제 #26
0
class OffsetRequest_v1(Request):
    API_KEY = 2
    API_VERSION = 1
    RESPONSE_TYPE = OffsetResponse_v1
    SCHEMA = Schema(
        ('replica_id', Int32),
        ('topics',
         Array(('topic', String('utf-8')),
               ('partitions', Array(('partition', Int32),
                                    ('timestamp', Int64))))))
    DEFAULTS = {'replica_id': -1}
예제 #27
0
class OffsetRequest_v2(Request):
    API_KEY = 2
    API_VERSION = 2
    RESPONSE_TYPE = OffsetResponse_v2
    SCHEMA = Schema(
        ('replica_id', Int32),
        ('isolation_level', Int8),  # <- added isolation_level
        ('topics',
         Array(('topic', String('utf-8')),
               ('partitions', Array(('partition', Int32),
                                    ('timestamp', Int64))))))
    DEFAULTS = {'replica_id': -1}
예제 #28
0
class MetadataResponse_v1(Response):
    API_KEY = 3
    API_VERSION = 1
    SCHEMA = Schema(
        ('brokers', Array(
            ('node_id', Int32),
            ('host', String('utf-8')),
            ('port', Int32),
            ('rack', String('utf-8')))),
        ('controller_id', Int32),
        ('topics', Array(
            ('error_code', Int16),
            ('topic', String('utf-8')),
            ('is_internal', Boolean),
            ('partitions', Array(
                ('error_code', Int16),
                ('partition', Int32),
                ('leader', Int32),
                ('replicas', Array(Int32)),
                ('isr', Array(Int32))))))
    )
예제 #29
0
class ConsumerProtocolMemberAssignment(Struct):
    SCHEMA = Schema(('version', Int16), ('assignment',
                                         Array(('topic', String('utf-8')),
                                               ('partitions', Array(Int32)))),
                    ('user_data', Bytes))

    def partitions(self):
        return [
            TopicPartition(topic, partition) for topic, partitions in
            self.assignment  # pylint: disable-msg=no-member
            for partition in partitions
        ]
예제 #30
0
class FetchRequest_v5(Request):
    # This may only be used in broker-broker api calls
    API_KEY = 1
    API_VERSION = 5
    RESPONSE_TYPE = FetchResponse_v5
    SCHEMA = Schema(
        ('replica_id', Int32), ('max_wait_time', Int32), ('min_bytes', Int32),
        ('max_bytes', Int32), ('isolation_level', Int8),
        ('topics',
         Array(('topic', String('utf-8')),
               ('partitions',
                Array(('partition', Int32), ('fetch_offset', Int64),
                      ('log_start_offset', Int64), ('max_bytes', Int32))))))