I wrote a simple protobuf generator based on the MessageId, so that I can
serialize them while this is fixed.
import itertools
import pulsar
def pb_varint(value, size):
value = pow(2,size) + value if value < 0 else value
s = "{{0:0{}b}}".format(size).format(value)
b = [int(s[max(0,i-7):i], 2) for i in range(size, 0, -7)]
b = reversed(list(itertools.dropwhile(lambda x: x == 0, reversed(b))))
b = list(map(lambda x: x+128, b))
if not b:
return b"\x00"
b[-1] = b[-1] - 128
return bytes(b)
def pb_messageid(mid):
if not isinstance(mid, str):
mid = str(mid)
mid = tuple(map(int, mid[1:-1].split(",")))
b = b""
for i in range(4):
b += bytes([(i+1)<<3]) + pb_varint(mid[[0,1,3,2][i]],
[64,64,32,32][i])
return b
[ Full content available at: https://github.com/apache/pulsar/issues/2708 ]
This message was relayed via gitbox.apache.org for [email protected]