Module: Kafka::Compression
- Defined in:
- lib/kafka/compression.rb
Constant Summary collapse
- CODEC_NAMES =
{ 1 => :gzip, 2 => :snappy, 3 => :lz4, }.freeze
- CODECS =
{ :gzip => GzipCodec.new, :snappy => SnappyCodec.new, :lz4 => LZ4Codec.new, }.freeze
Class Method Summary collapse
Class Method Details
.codecs ⇒ Object
21 22 23 |
# File 'lib/kafka/compression.rb', line 21 def self.codecs CODECS.keys end |
.find_codec(name) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/kafka/compression.rb', line 25 def self.find_codec(name) codec = CODECS.fetch(name) do raise "Unknown compression codec #{name}" end codec.load codec end |
.find_codec_by_id(codec_id) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/kafka/compression.rb', line 35 def self.find_codec_by_id(codec_id) codec_name = CODEC_NAMES.fetch(codec_id) do raise "Unknown codec id #{codec_id}" end find_codec(codec_name) end |