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 7e28a32 commit c4062c3
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lib/fluent/plugin/out_s3.rb
Original file line number Diff line number Diff line change
Expand Up @@ -632,17 +632,25 @@ def compress(chunk, tmp)
end

class ZstdCompressor < Compressor
DEFAULT_LEVEL = 3

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

def ext
'zst'.freeze
end

def content_type
'application/x-zst'.freeze
end

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

0 comments on commit c4062c3

Please sign in to comment.