[#1715] config: Add compression
config section
All checks were successful
Vulncheck / Vulncheck (push) Successful in 1m10s
Pre-commit hooks / Pre-commit (push) Successful in 1m34s
Build / Build Components (push) Successful in 1m50s
Tests and linters / gopls check (push) Successful in 3m49s
Tests and linters / Run gofumpt (push) Successful in 3m56s
Tests and linters / Staticcheck (push) Successful in 4m33s
Tests and linters / Lint (push) Successful in 4m37s
OCI image / Build container images (push) Successful in 4m45s
Tests and linters / Tests (push) Successful in 5m1s
Tests and linters / Tests with -race (push) Successful in 6m6s
All checks were successful
Vulncheck / Vulncheck (push) Successful in 1m10s
Pre-commit hooks / Pre-commit (push) Successful in 1m34s
Build / Build Components (push) Successful in 1m50s
Tests and linters / gopls check (push) Successful in 3m49s
Tests and linters / Run gofumpt (push) Successful in 3m56s
Tests and linters / Staticcheck (push) Successful in 4m33s
Tests and linters / Lint (push) Successful in 4m37s
OCI image / Build container images (push) Successful in 4m45s
Tests and linters / Tests (push) Successful in 5m1s
Tests and linters / Tests with -race (push) Successful in 6m6s
To group all `compression_*` parameters together. Change-Id: I11ad9600f731903753fef1adfbc0328ef75bbf87 Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
8c746a914a
commit
0ee7467da5
12 changed files with 105 additions and 155 deletions
|
@ -32,8 +32,8 @@ type Config struct {
|
|||
UncompressableContentTypes []string
|
||||
Level Level
|
||||
|
||||
UseCompressEstimation bool
|
||||
CompressEstimationThreshold float64
|
||||
EstimateCompressibility bool
|
||||
EstimateCompressibilityThreshold float64
|
||||
}
|
||||
|
||||
// zstdFrameMagic contains first 4 bytes of any compressed object
|
||||
|
@ -101,9 +101,9 @@ func (c *Compressor) Compress(data []byte) []byte {
|
|||
if c == nil || !c.Enabled {
|
||||
return data
|
||||
}
|
||||
if c.UseCompressEstimation {
|
||||
if c.EstimateCompressibility {
|
||||
estimated := compress.Estimate(data)
|
||||
if estimated >= c.CompressEstimationThreshold {
|
||||
if estimated >= c.EstimateCompressibilityThreshold {
|
||||
return c.compress(data)
|
||||
}
|
||||
return data
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue