Class: Fluent::Plugin::S3Output::ZstdCompressor
- Inherits:
-
Compressor
- Object
- Compressor
- Fluent::Plugin::S3Output::ZstdCompressor
- Defined in:
- lib/fluent/plugin/s3_compressor_zstd.rb
Instance Attribute Summary
Attributes inherited from Compressor
Instance Method Summary collapse
- #compress(chunk, tmp) ⇒ Object
- #content_type ⇒ Object
- #ext ⇒ Object
-
#initialize(opts = {}) ⇒ ZstdCompressor
constructor
A new instance of ZstdCompressor.
Methods inherited from Compressor
Constructor Details
#initialize(opts = {}) ⇒ ZstdCompressor
Returns a new instance of ZstdCompressor.
11 12 13 14 15 16 17 |
# File 'lib/fluent/plugin/s3_compressor_zstd.rb', line 11 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. raise Fluent::ConfigError, "failed to load 'zstd-ruby' gem" end |
Instance Method Details
#compress(chunk, tmp) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/fluent/plugin/s3_compressor_zstd.rb', line 27 def compress(chunk, tmp) compressed = Zstd.compress(chunk.read, level: @compress_config.level) tmp.write(compressed) rescue => e log.warn "zstd compression failed: #{e.}" raise end |
#content_type ⇒ Object
23 24 25 |
# File 'lib/fluent/plugin/s3_compressor_zstd.rb', line 23 def content_type 'application/x-zst'.freeze end |
#ext ⇒ Object
19 20 21 |
# File 'lib/fluent/plugin/s3_compressor_zstd.rb', line 19 def ext 'zst'.freeze end |