-
-
Notifications
You must be signed in to change notification settings - Fork 107
Refactor AMQPCodec #111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor AMQPCodec #111
Conversation
| start: gen_class(class) >> | ||
| end: gen_at_offset!(len, gen_be_u32!(end - start)) >> | ||
| gen_be_u8!(constants::FRAME_END) | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heh, I was pretty sure I did something similar already... found it: https://github.com/sozu-proxy/amq-protocol/blob/master/protocol/src/frame/generation.rs#L19
I thought I synced that a while ago but apparently I didn't.
Will sync all that stuff soonish after some testing
|
LGTM once we get a new cookie-factory release |
|
Btw, with this we can bring back and use the Sink impl right? |
|
Yep, I'm planning on adding a few more tests, I'll also restore the Sink impl |
The `AMQPCodec::encode` function overwrote the contents of the buffer given to it, forcing its users to flush the buffer after encoding each item. The new implementation simplifies `AMQPTransport` and especially allows for the removal of the `flush_needed` attribute.
|
Rebased on current master, now that cookie-factory 0.2.4 has been released |
|
Thanks, I'll push the rest tonight or tomorrow |
This will prevent putting too much strain on the allocator in the case of a frame consisting of many parts exceeding the buffer's capacity. Also, the threshold to a reallocation is now 1/4th of a frame, which is 1/8th of the space allocated.
Add a test with a frame more complex than the heartbeat one & a test regarding the behaviour of buffer capacity expansion.
|
Thanks ! |
The
AMQPCodec::encodefunction overwrote the contents of the buffergiven to it, forcing its users to flush the buffer after encoding each
item.
The new implementation simplifies
AMQPTransportand especially allowsfor the removal of the
flush_neededattribute.