Added constant for struct encoding
This commit is contained in:
parent
55f9dd4425
commit
d2571f6d50
1 changed files with 5 additions and 7 deletions
|
@ -29,10 +29,8 @@ INVALID_METADATA_LAYOUT = 2
|
|||
INVALID_DATA_TYPE = 3
|
||||
|
||||
META_ROUTE = "meta"
|
||||
|
||||
COMPRESSION_LEVEL = 3
|
||||
|
||||
|
||||
PACK_FORMAT = "Bh"
|
||||
|
||||
|
||||
class ConvertFailedError(ValueError):
|
||||
|
@ -76,7 +74,7 @@ class Meta:
|
|||
|
||||
|
||||
def create_metadata(data_type, converted_route, indexed_dict=False):
|
||||
return struct.pack("bh",
|
||||
return struct.pack(PACK_FORMAT,
|
||||
DATA_TYPES[data_type] if not indexed_dict else DATA_TYPES[INDEXED_DICT],
|
||||
converted_route)
|
||||
|
||||
|
@ -108,7 +106,7 @@ def pack_message(data, exchange_route, compression_level,
|
|||
|
||||
|
||||
def parse_metadata(message):
|
||||
metadata = struct.unpack("bh", message[:4])
|
||||
metadata = struct.unpack(PACK_FORMAT, message[:4])
|
||||
return Metadata(metadata[0], metadata[1])
|
||||
|
||||
|
||||
|
|
Reference in a new issue