[#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
|
@ -95,52 +95,9 @@ func WithLogger(l *logger.Logger) Option {
|
|||
}
|
||||
}
|
||||
|
||||
// WithCompressObjects returns option to toggle
|
||||
// compression of the stored objects.
|
||||
//
|
||||
// If true, Zstandard algorithm is used for data compression.
|
||||
//
|
||||
// If compressor (decompressor) creation failed,
|
||||
// the uncompressed option will be used, and the error
|
||||
// is recorded in the provided log.
|
||||
func WithCompressObjects(comp bool) Option {
|
||||
func WithCompression(comp compression.Config) Option {
|
||||
return func(c *cfg) {
|
||||
c.compression.Enabled = comp
|
||||
}
|
||||
}
|
||||
|
||||
func WithCompressionLevel(level compression.Level) Option {
|
||||
return func(c *cfg) {
|
||||
c.compression.Level = level
|
||||
}
|
||||
}
|
||||
|
||||
// WithCompressibilityEstimate returns an option to use
|
||||
// normilized compressibility estimate to decide compress
|
||||
// data or not.
|
||||
//
|
||||
// See https://github.com/klauspost/compress/blob/v1.17.2/compressible.go#L5
|
||||
func WithCompressibilityEstimate(v bool) Option {
|
||||
return func(c *cfg) {
|
||||
c.compression.UseCompressEstimation = v
|
||||
}
|
||||
}
|
||||
|
||||
// WithCompressibilityEstimateThreshold returns an option to set
|
||||
// normilized compressibility estimate threshold.
|
||||
//
|
||||
// See https://github.com/klauspost/compress/blob/v1.17.2/compressible.go#L5
|
||||
func WithCompressibilityEstimateThreshold(threshold float64) Option {
|
||||
return func(c *cfg) {
|
||||
c.compression.CompressEstimationThreshold = threshold
|
||||
}
|
||||
}
|
||||
|
||||
// WithUncompressableContentTypes returns option to disable decompression
|
||||
// for specific content types as seen by object.AttributeContentType attribute.
|
||||
func WithUncompressableContentTypes(values []string) Option {
|
||||
return func(c *cfg) {
|
||||
c.compression.UncompressableContentTypes = values
|
||||
c.compression.Config = comp
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue