mirror of
https://github.com/buger/goreplay.git
synced 2024-04-21 12:32:02 +00:00
the major purpose of this PR is to update modules to their recent **minor version**. this is helpful in terms of having update functionalities and fixing some issues caused by non-up-to-date modules.
29 lines
512 B
Go
29 lines
512 B
Go
package sarama
|
|
|
|
import (
|
|
"sync"
|
|
|
|
"github.com/klauspost/compress/zstd"
|
|
)
|
|
|
|
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
|
|
}
|