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-custom-0.7.7.26 lib/kafka/gzip_codec.rb
ruby-kafka-0.7.6 lib/kafka/gzip_codec.rb
ruby-kafka-0.7.6.beta2 lib/kafka/gzip_codec.rb
ruby-kafka-0.7.6.beta1 lib/kafka/gzip_codec.rb
ruby-kafka-0.7.5 lib/kafka/gzip_codec.rb
ruby-kafka-0.7.5.beta1 lib/kafka/gzip_codec.rb
ruby-kafka-0.7.4 lib/kafka/gzip_codec.rb
ruby-kafka-0.7.3 lib/kafka/gzip_codec.rb
ruby-kafka-0.7.2 lib/kafka/gzip_codec.rb
ruby-kafka-0.7.1.debugcorruption2 lib/kafka/gzip_codec.rb
ruby-kafka-0.7.1.messagecorruptiondebug lib/kafka/gzip_codec.rb
ruby-kafka-0.7.1 lib/kafka/gzip_codec.rb
ruby-kafka-0.7.1.beta2 lib/kafka/gzip_codec.rb
ruby-kafka-0.7.1.possible.pre.fetch.pre.fix lib/kafka/gzip_codec.rb
ruby-kafka-0.7.1.beta1 lib/kafka/gzip_codec.rb
ruby-kafka-0.7.0 lib/kafka/gzip_codec.rb
ruby-kafka-0.6.8 lib/kafka/gzip_codec.rb
ruby-kafka-0.7.0.beta2 lib/kafka/gzip_codec.rb
ruby-kafka-0.7.0.beta1 lib/kafka/gzip_codec.rb
ruby-kafka-0.7.0.alpha4 lib/kafka/gzip_codec.rb