2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-22 17:43:14 +00:00

Always use string type in msgpack

To facilitate py2/py3 consistency, for these
messages just always use the native string.
With this, python 2 strings will be unpacked as
strings by python 3.  This means bytes cannot be
passed, but we will suffer that limitation for now.
This commit is contained in:
Jarrod Johnson 2020-01-24 14:07:34 -05:00
parent b766e7b0ee
commit 8a9e9aa7b3
3 changed files with 8 additions and 8 deletions

View File

@ -737,15 +737,15 @@ def _forward_rsp(connection, res):
r = res.serialize()
except AttributeError:
if isinstance(res, Exception):
r = msgpack.packb(['Exception', str(res)], use_bin_type=True)
r = msgpack.packb(['Exception', str(res)], use_bin_type=False)
else:
r = msgpack.packb(
['Exception', 'Unable to serialize response ' + repr(res)],
use_bin_type=True)
use_bin_type=False)
except Exception:
r = msgpack.packb(
['Exception', 'Unable to serialize response ' + repr(res)],
use_bin_type=True)
use_bin_type=False)
rlen = len(r)
if not rlen:
return
@ -987,7 +987,7 @@ def dispatch_request(nodes, manager, element, configmanager, inputdata,
dreq = b'\x01\x03' + msgpack.packb(
{'name': myname, 'nodes': list(nodes),
'path': element,'tenant': configmanager.tenant,
'operation': operation, 'inputdata': inputdata}, use_bin_type=True)
'operation': operation, 'inputdata': inputdata}, use_bin_type=False)
tlvdata.send(remote, {'dispatch': {'name': myname, 'length': len(dreq)}})
remote.sendall(dreq)
while True:

View File

@ -37,7 +37,7 @@ class ConfluentException(Exception):
def serialize(self):
return msgpack.packb([self.__class__.__name__, [str(self)]],
use_bin_type=True)
use_bin_type=False)
@property
def apierrorstr(self):
@ -132,7 +132,7 @@ class PubkeyInvalid(ConfluentException):
def serialize(self):
return msgpack.packb([self.__class__.__name__, self.myargs],
use_bin_type=True)
use_bin_type=False)
def get_error_body(self):
return self.errorbody

View File

@ -116,7 +116,7 @@ class ConfluentMessage(object):
def serialize(self):
msg = [self.__class__.__name__]
msg.extend(self.myargs)
return msgpack.packb(msg, use_bin_type=True)
return msgpack.packb(msg, use_bin_type=False)
@classmethod
def deserialize(cls, data):
@ -231,7 +231,7 @@ class ConfluentNodeError(object):
def serialize(self):
return msgpack.packb(
[self.__class__.__name__, self.node, self.error],
use_bin_type=True)
use_bin_type=False)
@classmethod
def deserialize(cls, data):