diff options
Diffstat (limited to 'kafka/protocol/metadata.py')
-rw-r--r-- | kafka/protocol/metadata.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/kafka/protocol/metadata.py b/kafka/protocol/metadata.py new file mode 100644 index 0000000..810f1b8 --- /dev/null +++ b/kafka/protocol/metadata.py @@ -0,0 +1,29 @@ +from .struct import Struct +from .types import Array, Int16, Int32, Schema, String + + +class MetadataResponse(Struct): + 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)))))) + ) + + +class MetadataRequest(Struct): + API_KEY = 3 + API_VERSION = 0 + RESPONSE_TYPE = MetadataResponse + SCHEMA = Schema( + ('topics', Array(String('utf-8'))) + ) |