Sha256: bef14b52c5127465add5fb9c3472a9d5fd32f91cb6064f6c3855592425b6e4df

Contents?: true

Size: 543 Bytes

Versions: 31

Compression:

Stored size: 543 Bytes

Contents

# frozen_string_literal: true

module Kafka
  class GzipCodec
    def codec_id
      1
    end

    def load
      require "zlib"
    end

    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

    def decompress(data)
      buffer = StringIO.new(data)
      reader = Zlib::GzipReader.new(buffer)
      reader.read
    end
  end
end

Version data entries

31 entries across 31 versions & 2 rubygems

Version Path
ruby-kafka-0.6.7 lib/kafka/gzip_codec.rb
ruby-kafka-0.6.6 lib/kafka/gzip_codec.rb
ruby-kafka-0.6.5 lib/kafka/gzip_codec.rb
ruby-kafka-0.6.4 lib/kafka/gzip_codec.rb
ruby-kafka-0.7.0.alpha3 lib/kafka/gzip_codec.rb
ruby-kafka-0.7.0.alpha2 lib/kafka/gzip_codec.rb
ruby-kafka-0.7.0.alpha1 lib/kafka/gzip_codec.rb
ruby-kafka-0.6.3 lib/kafka/gzip_codec.rb
ruby-kafka-0.6.2 lib/kafka/gzip_codec.rb
ruby-kafka-0.6.1 lib/kafka/gzip_codec.rb
ruby-kafka-0.6.0 lib/kafka/gzip_codec.rb