khenaidoo | 7d3c558 | 2021-08-11 18:09:44 -0400 | [diff] [blame] | 1 | package sarama |
2 | |||||
3 | import ( | ||||
4 | "github.com/klauspost/compress/zstd" | ||||
5 | ) | ||||
6 | |||||
7 | var ( | ||||
8 | zstdDec, _ = zstd.NewReader(nil) | ||||
9 | zstdEnc, _ = zstd.NewWriter(nil, zstd.WithZeroFrames(true)) | ||||
10 | ) | ||||
11 | |||||
12 | func zstdDecompress(dst, src []byte) ([]byte, error) { | ||||
13 | return zstdDec.DecodeAll(src, dst) | ||||
14 | } | ||||
15 | |||||
16 | func zstdCompress(dst, src []byte) ([]byte, error) { | ||||
17 | return zstdEnc.EncodeAll(src, dst), nil | ||||
18 | } |