mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-14 02:43:36 +00:00
vendor update for CSI 0.3.0
This commit is contained in:
21
vendor/google.golang.org/grpc/encoding/gzip/gzip.go
generated
vendored
21
vendor/google.golang.org/grpc/encoding/gzip/gzip.go
generated
vendored
@ -23,6 +23,7 @@ package gzip
|
||||
|
||||
import (
|
||||
"compress/gzip"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"sync"
|
||||
@ -46,6 +47,26 @@ type writer struct {
|
||||
pool *sync.Pool
|
||||
}
|
||||
|
||||
// SetLevel updates the registered gzip compressor to use the compression level specified (gzip.HuffmanOnly is not supported).
|
||||
// NOTE: this function must only be called during initialization time (i.e. in an init() function),
|
||||
// and is not thread-safe.
|
||||
//
|
||||
// The error returned will be nil if the specified level is valid.
|
||||
func SetLevel(level int) error {
|
||||
if level < gzip.DefaultCompression || level > gzip.BestCompression {
|
||||
return fmt.Errorf("grpc: invalid gzip compression level: %d", level)
|
||||
}
|
||||
c := encoding.GetCompressor(Name).(*compressor)
|
||||
c.poolCompressor.New = func() interface{} {
|
||||
w, err := gzip.NewWriterLevel(ioutil.Discard, level)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return &writer{Writer: w, pool: &c.poolCompressor}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *compressor) Compress(w io.Writer) (io.WriteCloser, error) {
|
||||
z := c.poolCompressor.Get().(*writer)
|
||||
z.Writer.Reset(w)
|
||||
|
Reference in New Issue
Block a user