From a85e09df89a43de5b659a0fa4ed35bec37c60e04 Mon Sep 17 00:00:00 2001 From: Dana Powers Date: Sat, 28 Nov 2015 19:41:06 +0800 Subject: Rework protocol type definition: AbstractType, Schema, Struct --- kafka/protocol/offset.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 kafka/protocol/offset.py (limited to 'kafka/protocol/offset.py') diff --git a/kafka/protocol/offset.py b/kafka/protocol/offset.py new file mode 100644 index 0000000..942bdbf --- /dev/null +++ b/kafka/protocol/offset.py @@ -0,0 +1,32 @@ +from .struct import Struct +from .types import Array, Int16, Int32, Int64, Schema, String + + +class OffsetRequest(Struct): + API_KEY = 2 + API_VERSION = 0 + SCHEMA = Schema( + ('replica_id', Int32), + ('topics', Array( + ('topic', String('utf-8')), + ('partitions', Array( + ('partition', Int32), + ('time', Int64), + ('max_offsets', Int32))))) + ) + DEFAULTS = { + 'replica_id': -1 + } + + +class OffsetResponse(Struct): + API_KEY = 2 + API_VERSION = 0 + SCHEMA = Schema( + ('topics', Array( + ('topic', String('utf-8')), + ('partitions', Array( + ('partition', Int32), + ('error_code', Int16), + ('offsets', Array(Int64)))))) + ) -- cgit v1.2.1