Created
May 27, 2023 07:26
-
-
Save iamazeem/49ae45a94f33cbc22232e2a0a538918e to your computer and use it in GitHub Desktop.
fluentd S3 zstd compressor
This file contains 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
require 'zstd' | |
module Fluent::Plugin | |
class S3Output | |
class LZMA2Compressor < Compressor | |
S3Output.register_compressor('zstd', self) | |
def initialize(options = {}) | |
begin | |
require 'zstd' | |
rescue LoadError | |
raise Fluent::ConfigError, 'zstd gem not installed, run: gem install zstd' | |
end | |
end | |
def ext | |
'zst'.freeze | |
end | |
def compress(chunk, tmp) | |
s = StringIO.new | |
chunk.write_to(s) | |
tmp.write(Zstd.new.compress(s.string)) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment