-
Notifications
You must be signed in to change notification settings - Fork 219
Add Zstd compression support to S3 plugin #439
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
Merged
Merged
Changes from 12 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
ed12eed
Bump actions/checkout from 3 to 4
dependabot[bot] 796d6c9
feat: Add Zstd compression support for S3 plugin
57ba441
Change zstd-ruby to runtime dependencies
ddukbg 6f84c65
Remove redundant bundler installation from GitHub Actions workflow
ddukbg 7f6e51c
Remove duplicate ZstdCompressor class as per maintainer's comments
ddukbg 6aa84f4
Remove ZstdCompressor tests from test_in_s3.rb as per maintainer's co…
ddukbg dd3bafb
Add ZstdCompressor test cases to test_out_s3.rb as per maintainer's c…
ddukbg 0ad8cdf
Merge pull request #2 from ddukbg/fix/pr-comment
ddukbg 7e28a32
refactor: Remove unnecessary whitespace
ddukbg 904a043
fix: Add proper compression level handling to ZstdCompressor
ddukbg e31e889
test: Add tests for Zstd compression level configuration
ddukbg fa2a609
fix: Improve ZSTD compression implementation - Remove unnecessary lin…
ddukbg 08448a1
refactor: Simplify ZSTD compression implementation
ddukbg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
require 'zstd-ruby' | ||
|
||
module Fluent::Plugin | ||
class S3Output | ||
class ZstdCompressor < Compressor | ||
S3Output.register_compressor('zstd', self) | ||
|
||
config_section :compress, param_name: :compress_config, init: true, multi: false do | ||
desc "Compression level for zstd (1-22)" | ||
config_param :level, :integer, default: 3 | ||
end | ||
|
||
def ext | ||
'zst'.freeze | ||
end | ||
|
||
def content_type | ||
'application/x-zst'.freeze | ||
end | ||
|
||
def compress(chunk, tmp) | ||
w = StringIO.new | ||
chunk.write_to(w) | ||
w.rewind | ||
compressed = Zstd.compress(w.read, level: @compress_config.level) | ||
tmp.binmode | ||
tmp.rewind | ||
tmp.write(compressed) | ||
tmp.rewind | ||
ddukbg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
rescue => e | ||
log.warn "zstd compression failed: #{e.message}" | ||
raise | ||
end | ||
end | ||
end | ||
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.