API refactor
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2025-10-07 16:25:52 +09:00
parent 76d0d86211
commit 91c7e04474
1171 changed files with 81940 additions and 44117 deletions

View File

@@ -187,14 +187,21 @@ def _detect_xerial_stream(payload):
The version is the version of this format as written by xerial,
in the wild this is currently 1 as such we only support v1.
Compat is there to claim the miniumum supported version that
Compat is there to claim the minimum supported version that
can read a xerial block stream, presently in the wild this is
1.
"""
if len(payload) > 16:
header = struct.unpack('!' + _XERIAL_V1_FORMAT, bytes(payload)[:16])
return header == _XERIAL_V1_HEADER
magic = struct.unpack('!' + _XERIAL_V1_FORMAT[:8], bytes(payload)[:8])
version, compat = struct.unpack('!' + _XERIAL_V1_FORMAT[8:], bytes(payload)[8:16])
# Until there is more than one way to do xerial blocking, the version + compat
# fields can be ignored. Also some producers (i.e., redpanda) are known to
# incorrectly encode these as little-endian, and that causes us to fail decoding
# when we otherwise would have succeeded.
# See https://github.com/dpkp/kafka-python/issues/2414
if magic == _XERIAL_V1_HEADER[:8]:
return True
return False