-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
feat: Add support for configuring compression levels #11805
base: main
Are you sure you want to change the base?
feat: Add support for configuring compression levels #11805
Conversation
7bbcdeb
to
ad9e1ee
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #11805 +/- ##
==========================================
+ Coverage 91.44% 91.53% +0.08%
==========================================
Files 446 445 -1
Lines 23742 23760 +18
==========================================
+ Hits 21712 21749 +37
+ Misses 1654 1633 -21
- Partials 376 378 +2 ☔ View full report in Codecov by Sentry. |
b9aedbf
to
853d79f
Compare
853d79f
to
ad9a8a3
Compare
# Use this changelog template to create an entry for release notes. | ||
|
||
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' | ||
change_type: 'breaking' |
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.
Not breaking anymore
# (Optional) One or more lines of additional information to render under the primary note. | ||
# These lines will be padded with 2 spaces and then inserted directly into the document. | ||
# Use pipe (|) for multiline entries. | ||
subtext: |
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.
Please add more details here describing a new field
import "fmt" | ||
import ( | ||
"fmt" | ||
) |
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.
Nit please avoid unrelated changes
@@ -36,7 +36,7 @@ require ( | |||
github.com/golang/snappy v0.0.4 // indirect | |||
github.com/google/uuid v1.6.0 // indirect | |||
github.com/json-iterator/go v1.1.12 // indirect | |||
github.com/klauspost/compress v1.17.9 // indirect | |||
github.com/klauspost/compress v1.17.11 // indirect |
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.
Why is this change? It doesn't require new version right?
compressor *compressor | ||
rt http.RoundTripper | ||
compressionType configcompression.Type | ||
CompressionParams configcompression.CompressionParams |
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.
to be consistent
CompressionParams configcompression.CompressionParams | |
compressionParams configcompression.CompressionParams |
tests := []struct { | ||
name string | ||
encoding configcompression.Type | ||
enclevel configcompression.Level |
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.
shoud be level
or encLevel
} | ||
client, err := clientSettings.ToClient(context.Background(), componenttest.NewNopHost(), componenttest.NewNopTelemetrySettings()) | ||
require.NoError(t, err) | ||
res, err := client.Do(req) | ||
if tt.shouldError { | ||
assert.Error(t, err) | ||
require.Error(t, err) |
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.
should not be changed
@@ -104,16 +119,26 @@ func TestHTTPClientCompression(t *testing.T) { | |||
|
|||
req, err := http.NewRequest(http.MethodGet, srv.URL, reqBody) | |||
require.NoError(t, err, "failed to create request to test handler") | |||
|
|||
compressionType := tt.encoding | |||
err = compressionType.UnmarshalText([]byte(tt.encoding)) |
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.
Why do we need UnmarshalText?
- SpeedFastest: `1` | ||
- SpeedDefault: `3` | ||
- SpeedBetterCompression: `6` | ||
- SpeedBestCompression: `11` |
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.
Does it mean that zstd
has more levels? I see we don't validate that
// Checks the validity of zlib/gzip/flate compression levels | ||
func isValidLevel(level configcompression.Level) bool { | ||
return level == zlib.DefaultCompression || | ||
level == configcompression.LevelNone || |
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.
Why not zlib.NoCompression
?
level == configcompression.LevelNone || | ||
level == zlib.HuffmanOnly || | ||
level == zlib.NoCompression || | ||
level == zlib.BestSpeed || |
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.
This seems redundant as we check it in the next line
Description
Add the option of configuring compression levels. This is not intended to be a breaking change for the user.
Link to tracking issue
Issue - #10467
Testing
Unit tests were added/changed