Class: Kafka::GzipCodec
- Inherits:
-
Object
- Object
- Kafka::GzipCodec
- Defined in:
- lib/kafka/gzip_codec.rb
Instance Method Summary collapse
- #codec_id ⇒ Object
- #compress(data) ⇒ Object
- #decompress(data) ⇒ Object
- #load ⇒ Object
- #produce_api_min_version ⇒ Object
Instance Method Details
#codec_id ⇒ Object
5 6 7 |
# File 'lib/kafka/gzip_codec.rb', line 5 def codec_id 1 end |
#compress(data) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/kafka/gzip_codec.rb', line 17 def compress(data) buffer = StringIO.new buffer.set_encoding(Encoding::BINARY) writer = Zlib::GzipWriter.new(buffer, Zlib::DEFAULT_COMPRESSION, Zlib::DEFAULT_STRATEGY) writer.write(data) writer.close buffer.string end |
#decompress(data) ⇒ Object
28 29 30 31 32 |
# File 'lib/kafka/gzip_codec.rb', line 28 def decompress(data) buffer = StringIO.new(data) reader = Zlib::GzipReader.new(buffer) reader.read end |
#load ⇒ Object
13 14 15 |
# File 'lib/kafka/gzip_codec.rb', line 13 def load require "zlib" end |
#produce_api_min_version ⇒ Object
9 10 11 |
# File 'lib/kafka/gzip_codec.rb', line 9 def produce_api_min_version 0 end |