Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
1 contributor

Users who have contributed to this file

28 lines (22 sloc) 511 Bytes
package sarama
import (
"github.com/klauspost/compress/zstd"
"sync"
)
var (
zstdDec *zstd.Decoder
zstdEnc *zstd.Encoder
zstdEncOnce, zstdDecOnce sync.Once
)
func zstdDecompress(dst, src []byte) ([]byte, error) {
zstdDecOnce.Do(func() {
zstdDec, _ = zstd.NewReader(nil)
})
return zstdDec.DecodeAll(src, dst)
}
func zstdCompress(dst, src []byte) ([]byte, error) {
zstdEncOnce.Do(func() {
zstdEnc, _ = zstd.NewWriter(nil, zstd.WithZeroFrames(true))
})
return zstdEnc.EncodeAll(src, dst), nil
}
You can’t perform that action at this time.