-
Notifications
You must be signed in to change notification settings - Fork 13
Factor batching logic out of the cohttp-lwt client #97
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
Conversation
This will allow resuing the batching logic in the Eio client. As a followup, we should refactor the ocurl client to use the same batcher.
c-cube
left a comment
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.
I think it's great! There's a couple small nitpicks but this is going to be much nicer (and factored)!
Since we need to traverse the elements added to count up the new size, we can use that pass to add the elements onto our FIFO queue, and then drain the queue in one last pass to reverse. IIUC, this should give us liner complexity of the batch retrieval.
|
Thanks for the helpful review! Should be ready for a second look! I've re-tested it against #96 locally. |
c-cube
left a comment
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.
Looks good!
This will allow reusing the batching logic in the Eio client. As a followup, we should refactor the ocurl client to use the same batcher.
Most changes here are purely mechanical, and just a matter of relocating the batching logic into its own module. Tho a few small cleanups were added:
Batchlogic is specialized to storing lists of lists its element type, which allows us to move the list flattening logic into the pop logic, rather than having to handle this in the clients. This specialization is justified because this is not a general purpose batching data-structure, but already highly specialized to our particular application.pushfunction that returned a bool, and renamedpush'topush.n_droppedcounter out of the batcher, instead having thepushfunction return a value to report if dropping occurred, which the client can then handle as needed.This PR does not reuse the new
Batchmodule for the ocurl client, but you can see what that would look like in my exploratory branch if your curious :)I have tested this locally against on top of the branch for #96, and the exact same signals are produced.