Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/lz4 codec #499

Merged
merged 4 commits into from
Dec 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/kafka/compression.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require "kafka/snappy_codec"
require "kafka/gzip_codec"
require "kafka/lz4_codec"

module Kafka
module Compression
Expand All @@ -8,6 +9,7 @@ def self.find_codec(name)
when nil then nil
when :snappy then SnappyCodec.new
when :gzip then GzipCodec.new
when :lz4 then LZ4Codec.new
else raise "Unknown compression codec #{name}"
end
end
Expand All @@ -16,6 +18,7 @@ def self.find_codec_by_id(codec_id)
case codec_id
when 1 then GzipCodec.new
when 2 then SnappyCodec.new
when 3 then LZ4Codec.new
else raise "Unknown codec id #{codec_id}"
end
end
Expand Down
21 changes: 21 additions & 0 deletions lib/kafka/lz4_codec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module Kafka
class LZ4Codec
def initialize
require "extlz4"
rescue LoadError
raise LoadError, "using lz4 compression requires adding a dependency on the `extlz4` gem to your Gemfile."
end

def codec_id
3
end

def compress(data)
LZ4.encode(data)
end

def decompress(data)
LZ4.decode(data)
end
end
end
2 changes: 1 addition & 1 deletion lib/kafka/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Kafka
VERSION = "0.5.1"
VERSION = "0.5.2"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no reason to bump the ruby-kafka version.

end
1 change: 1 addition & 0 deletions ruby-kafka.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "rspec-benchmark"
spec.add_development_dependency "activesupport"
spec.add_development_dependency "snappy"
spec.add_development_dependency "extlz4"
spec.add_development_dependency "colored"
spec.add_development_dependency "rspec_junit_formatter", "0.2.2"
spec.add_development_dependency "dogstatsd-ruby", ">= 3.0.0"
Expand Down