Scott Baker | ed4efab | 2020-01-13 19:12:25 -0800 | [diff] [blame] | 1 | package sarama |
| 2 | |
| 3 | import ( |
| 4 | "github.com/klauspost/compress/zstd" |
Scott Baker | ed4efab | 2020-01-13 19:12:25 -0800 | [diff] [blame] | 5 | ) |
| 6 | |
| 7 | var ( |
David K. Bainbridge | bd6b288 | 2021-08-26 13:31:02 +0000 | [diff] [blame] | 8 | zstdDec, _ = zstd.NewReader(nil) |
| 9 | zstdEnc, _ = zstd.NewWriter(nil, zstd.WithZeroFrames(true)) |
Scott Baker | ed4efab | 2020-01-13 19:12:25 -0800 | [diff] [blame] | 10 | ) |
| 11 | |
| 12 | func zstdDecompress(dst, src []byte) ([]byte, error) { |
Scott Baker | ed4efab | 2020-01-13 19:12:25 -0800 | [diff] [blame] | 13 | return zstdDec.DecodeAll(src, dst) |
| 14 | } |
| 15 | |
| 16 | func zstdCompress(dst, src []byte) ([]byte, error) { |
Scott Baker | ed4efab | 2020-01-13 19:12:25 -0800 | [diff] [blame] | 17 | return zstdEnc.EncodeAll(src, dst), nil |
| 18 | } |