Add Message and MessageSet HEADER_SIZE bytes

This commit is contained in:
Dana Powers
2016-01-23 15:19:55 -08:00
parent 48e96822b3
commit ee19cbfa4a

View File

@@ -20,6 +20,7 @@ class Message(Struct):
CODEC_MASK = 0x03
CODEC_GZIP = 0x01
CODEC_SNAPPY = 0x02
HEADER_SIZE = 14 # crc(4), magic(1), attributes(1), key+value size(4*2)
def __init__(self, value, key=None, magic=0, attributes=0, crc=0):
assert value is None or isinstance(value, bytes), 'value must be bytes'
@@ -83,6 +84,7 @@ class MessageSet(AbstractType):
('message_size', Int32),
('message', Message.SCHEMA)
)
HEADER_SIZE = 12 # offset + message_size
@classmethod
def encode(cls, items, size=True, recalc_message_size=True):