github.com/streamdal/segmentio-kafka-go@v0.4.47-streamdal/compression.go (about) 1 package kafka 2 3 import ( 4 "errors" 5 6 "github.com/segmentio/kafka-go/compress" 7 ) 8 9 type Compression = compress.Compression 10 11 const ( 12 Gzip Compression = compress.Gzip 13 Snappy Compression = compress.Snappy 14 Lz4 Compression = compress.Lz4 15 Zstd Compression = compress.Zstd 16 ) 17 18 type CompressionCodec = compress.Codec 19 20 var ( 21 errUnknownCodec = errors.New("the compression code is invalid or its codec has not been imported") 22 ) 23 24 // resolveCodec looks up a codec by Code(). 25 func resolveCodec(code int8) (CompressionCodec, error) { 26 codec := compress.Compression(code).Codec() 27 if codec == nil { 28 return nil, errUnknownCodec 29 } 30 return codec, nil 31 }