Skip to content

Commit

Permalink
dependency: remove zstd-ruby (#445)
Browse files Browse the repository at this point in the history
Remove `zstd-ruby` from the dependencies.
We need to manually install `zstd-ruby` to use
`zstd` compression.

`zstd-ruby` gem needs to build native extensions.
It is not desirable to require a build environment for this
optional feature.

Signed-off-by: Daijiro Fukuda <[email protected]>
  • Loading branch information
daipom authored Nov 15, 2024
1 parent feb30a6 commit 99ba470
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion fluent-plugin-s3.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ Gem::Specification.new do |gem|
gem.add_dependency "fluentd", [">= 0.14.22", "< 2"]
gem.add_dependency "aws-sdk-s3", "~> 1.60"
gem.add_dependency "aws-sdk-sqs", "~> 1.23"
gem.add_dependency 'zstd-ruby'
gem.add_development_dependency "rake", ">= 0.9.2"
gem.add_development_dependency "test-unit", ">= 3.0.8"
gem.add_development_dependency "test-unit-rr", ">= 1.0.3"
gem.add_development_dependency "timecop"
# aws-sdk-core requires one of ox, oga, libxml, nokogiri or rexml,
# and rexml is no longer default gem as of Ruby 3.0.
gem.add_development_dependency "rexml"
gem.add_development_dependency "zstd-ruby"
end
12 changes: 9 additions & 3 deletions lib/fluent/plugin/s3_compressor_zstd.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require 'zstd-ruby'

module Fluent::Plugin
class S3Output
class ZstdCompressor < Compressor
Expand All @@ -10,6 +8,14 @@ class ZstdCompressor < Compressor
config_param :level, :integer, default: 3
end

def initialize(opts = {})
super
require 'zstd-ruby'
rescue LoadError => e
log.error "failed to load zstd-ruby gem. You need to manually install 'zstd-ruby' gem to use 'zstd'.", error: e.message
raise Fluent::ConfigError, "failed to load 'zstd-ruby' gem"
end

def ext
'zst'.freeze
end
Expand All @@ -27,4 +33,4 @@ def compress(chunk, tmp)
end
end
end
end
end

0 comments on commit 99ba470

Please sign in to comment.