-
Notifications
You must be signed in to change notification settings - Fork 85
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
Compression promises #50
Conversation
a6756bd
to
224a9e8
Compare
This looks great, thanks! Just that I wanted to remove sync compression in version 3.0. Sync/Async compression was created for a performance comparison test which never happened unfortunately but in most cases async code is preferred in Node. |
That's great! The only changes that would have to be made in the Client, then, for removing the sync compression methods would be to remove the two places where there's a branch for https://github.com/oleksiyk/kafka/pull/50/files#diff-50cfa59973c04321b5da0c6da0fdf4feR643 and https://github.com/oleksiyk/kafka/pull/50/files#diff-50cfa59973c04321b5da0c6da0fdf4feR634 |
Honestly, I think I would prefer to keep existing code. It might not look great but it does less asynchronous mappings such as: https://github.com/cjlarose/kafka/blob/compression-promises/lib/client.js#L266-L267 Existing code is bad because its using huge side effect by modifying variable from upper scope: https://github.com/oleksiyk/kafka/blob/master/lib/client.js#L248 The downside of proposed changes is duplicate async iteration(s) which will render useless context switching. |
If you're concerned about the performance implications of the changes, I agree with you that the proposed changes to However, I'd encourage you to take a look at the changes made to In the old code, in the case where the message sets are compressed, each time a message set is decompressed, a new intermediate Array is generated with a call to The new code instead collects all of the results at the end and generates a single new array with the call to |
You are right, |
Sounds good to me! |
Manually merged in master. Thanks a lot! |
There were a number of branches in the
Client
code that were trying to deal with whether or not the compression technique was synchronous or asynchronous. One of the greatest benefits of usingPromise
s, though, is that they can unify the interactions between sync and async code.I modified the synchronous compression functions to return
Promise
s, just like their asynchronous counterparts. This allowed for a number of upstream simplifications of theClient
code.I split the changes up into separate commits to make reviewing easier, but I can squash if it is preferred.