qweeze / rstream

A Python asyncio-based client for RabbitMQ Streams
MIT License
84 stars 13 forks source link

AMQP encoder does not handle large integers #212

Open wrobell opened 1 month ago

wrobell commented 1 month ago

I would like to update RbFly performance tests for AMQP codecs (https://wrobell.dcmod.org/rbfly/performance.html), but it seems the encoder you are using does not support large integers, so the bug report

The following

from rstream.amqp import AMQPMessage
bytes(AMQPMessage(body={'large-int': 2 ** 32 + 1}))

results in

File ~/projects/rbfly/.venv/lib/python3.12/site-packages/rstream/_pyamqp/_encode.py:262, in encode_int(output, value, with_constructor, use_smallest)
    260     output.extend(struct.pack(">i", value))
    261 except struct.error as exc:
--> 262     raise ValueError("Value supplied for int invalid: {}".format(value)) from exc

ValueError: Value supplied for int invalid: 4294967297
Gsantomaggio commented 1 month ago

Thank you @wrobell we will have a look as soon as poosible

DanielePalaia commented 1 month ago

Hi @wrobell

this branch should solve the issue: https://github.com/qweeze/rstream/pull/214

Could you test it?

Thanks, Daniele