File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed
Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change 22
33import struct
44from struct import error
5+ import uuid
56
67from kafka .protocol .abstract import AbstractType
78
@@ -90,6 +91,18 @@ def decode(cls, data):
9091 return _unpack (cls ._unpack , data .read (8 ))
9192
9293
94+ class UUID (AbstractType ):
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+
93106class String (AbstractType ):
94107 def __init__ (self , encoding = 'utf-8' ):
95108 self .encoding = encoding
@@ -348,7 +361,6 @@ def encode(cls, value):
348361
349362
350363class CompactArray (Array ):
351-
352364 def encode (self , items ):
353365 if items is None :
354366 return UnsignedVarInt32 .encode (0 )
@@ -362,4 +374,3 @@ def decode(self, data):
362374 if length == - 1 :
363375 return None
364376 return [self .array_of .decode (data ) for _ in range (length )]
365-
You can’t perform that action at this time.
0 commit comments