File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed
Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change 11import struct
22from struct import error
3+ import uuid
34
45from kafka .protocol .abstract import AbstractType
56
@@ -88,6 +89,20 @@ def decode(cls, data):
8889 return _unpack (cls ._unpack , data .read (8 ))
8990
9091
92+ class UUID (AbstractType ):
93+ ZERO_UUID = uuid .UUID (int = 0 )
94+
95+ @classmethod
96+ def encode (cls , value ):
97+ if isinstance (value , uuid .UUID ):
98+ return value .bytes
99+ return uuid .UUID (value ).bytes
100+
101+ @classmethod
102+ def decode (cls , data ):
103+ return uuid .UUID (bytes = data .read (16 ))
104+
105+
91106class String (AbstractType ):
92107 def __init__ (self , encoding = 'utf-8' ):
93108 self .encoding = encoding
@@ -346,7 +361,6 @@ def encode(cls, value):
346361
347362
348363class CompactArray (Array ):
349-
350364 def encode (self , items ):
351365 if items is None :
352366 return UnsignedVarInt32 .encode (0 )
You can’t perform that action at this time.
0 commit comments