Skip to content

Instantly share code, notes, and snippets.

View kppullin's full-sized avatar

Kevin Pullin kppullin

View GitHub Profile
@kppullin
kppullin / consumer-offset-parser.py
Last active January 7, 2022 00:27
Python Kafka __consumer_offset binary parser/formatter
# Port of `kafka/core/src/main/scala/kafka/coordinator/group/GroupMetadataManager.scala -> OffsetsMessageFormatter`
# `key` and `value` are the raw byte arrays from the `__consumer_offsets` topic.
import io
import struct
key_reader = io.BytesIO(key)
value_reader = io.BytesIO(value)
key_version = struct.unpack('>h', key_reader.read(2))[0]