Add transport compression to attic push #43
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
My buildserver is behind a 4Mbps uplink, so it is very beneficial for me if attic supported transport compression. This pull requests adds transport compression to both the server and the client.
It adds support for the Content-Encoding header to /api/v1/upload-path, with the following compression formats:
As per the standard, it compresses the whole request body, including the narinfo file. X-Attic-Nar-Info-Preamble-Size refers to the byte offset in the decompressed body. Ideally this would reuse the request decompression middleware from tower-http, but i didn’t figure out how to get it to work, due to differing body types.
The client portion of the change adds a configuration option that changes transport compression to the server. This option is scoped to each server, as for example an attic server running on LAN might not need transport compression.
The client compression code is a bit suboptimal, due to how async_compression and reqwest use different types, and more efficient ways of adapting an AsyncRead to a Stream require tokio (which fwict would make it more difficult to adapt a stream into an AsyncRead first)