dehora / nakadi-java

🌀 Client library for the Nakadi Event Broker (examples: http://bit.ly/njc-examples, site: https://dehora.github.io/nakadi-java/)
MIT License
30 stars 19 forks source link

Allow event publishing to be compressed #369

Closed dehora closed 2 years ago

dehora commented 2 years ago

If enablePublishingCompression is set on the client, posts will be submitted with compression. The entity is buffered and compressed before sending, which allows the content length to be submitted, at the cost of initial buffering. Library users will have to turn on compression support to avoid changing the default behaviour of previous versions. Placing compression behind a CompressionSupport interface allows alternative compression providers in the future. The default implementation is gzip.

String posting is handled slightly differently to object posting; in particular strings arenot minified before compression (doing this would incur the overhead of marshalling the string to an object to minify it).

For gzip, an alternative to look at in the future is to stream and gzip at the same time. This would avoid the initial buffer, and would require sending Transfer-Encoding: chunked in place of the Content-Length, since the length wouldn't be know in advance.

conorclifford commented 2 years ago

👍