Skip to content

Commit

Permalink
feat: Add compression level configuration to ZstdCompressor
Browse files Browse the repository at this point in the history
Signed-off-by: ddukbg <[email protected]>
  • Loading branch information
ddukbg committed Nov 2, 2024
1 parent 5484f1d commit cbfdf73
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions lib/fluent/plugin/out_s3.rb
Original file line number Diff line number Diff line change
Expand Up @@ -634,8 +634,8 @@ def compress(chunk, tmp)
class ZstdCompressor < Compressor
DEFAULT_LEVEL = 3

def initialize(level = DEFAULT_LEVEL)
@level = level
def initialize(level = nil)
@level = level || DEFAULT_LEVEL
end

def ext
Expand All @@ -647,11 +647,14 @@ def content_type
end

def compress(chunk, tmp)
compressed_data = Zstd.compress(chunk.read, level: @level)
tmp.write(compressed_data)
rescue => e
log.warn "zstd compression failed: #{e.message}"
raise e
begin
data = chunk.read
compressed_data = Zstd.compress(data, level: @level)
tmp.write(compressed_data)
rescue => e
log.warn "zstd compression failed: #{e.message}"
raise e
end
end
end

Expand Down

0 comments on commit cbfdf73

Please sign in to comment.