Skip to content

Instantly share code, notes, and snippets.

@iamazeem
Created May 27, 2023 07:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iamazeem/49ae45a94f33cbc22232e2a0a538918e to your computer and use it in GitHub Desktop.
Save iamazeem/49ae45a94f33cbc22232e2a0a538918e to your computer and use it in GitHub Desktop.
fluentd S3 zstd compressor
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