class Fluent::AzureStorageGen2Output::GzipCommandCompressor
Public Instance Methods
compress(chunk, tmp)
click to toggle source
# File lib/fluent/plugin/azurestorage_gen2_compressor_gzip_command.rb, line 21 def compress(chunk, tmp) chunk_is_file = @buffer_type == 'file' path = if chunk_is_file chunk.path else w = Tempfile.new("chunk-gzip-tmp") w.binmode chunk.write_to(w) w.close w.path end res = system "gzip #{@command_parameter} -c #{path} > #{tmp.path}" unless res log.warn "failed to execute gzip command. Fallback to GzipWriter. status = #{$?}" begin tmp.truncate(0) gw = Zlib::GzipWriter.new(tmp) chunk.write_to(gw) gw.close ensure gw.close rescue nil end end ensure unless chunk_is_file w.close(true) rescue nil end end
configure(conf)
click to toggle source
Calls superclass method
# File lib/fluent/plugin/azurestorage_gen2_compressor_gzip_command.rb, line 8 def configure(conf) super check_command('gzip') end
content_type()
click to toggle source
# File lib/fluent/plugin/azurestorage_gen2_compressor_gzip_command.rb, line 17 def content_type 'application/x-gzip'.freeze end
ext()
click to toggle source
# File lib/fluent/plugin/azurestorage_gen2_compressor_gzip_command.rb, line 13 def ext 'gz'.freeze end