Class: Fluent::HttpFileUploadOutput

Inherits:
BufferedOutput
  • Object
show all
Includes:
SetTimeKeyMixin
Defined in:
lib/fluent/plugin/out_http_file_upload.rb

Instance Method Summary collapse

Instance Method Details

#configure(conf) ⇒ Object

TODO: support compression TODO: support gzipped transferring



46
47
48
49
50
51
52
53
54
55
56
# File 'lib/fluent/plugin/out_http_file_upload.rb', line 46

def configure(conf)
  super

  @formatter = Plugin.new_formatter(@format)
  @formatter.configure(conf)
  @client = HTTPClient.new(agent_name: @user_agent, default_header: @headers)
  # @client.debug_dev = $stderr
  if @uri.start_with?("https://")
    @client.ssl_config.verify_mode = @ssl_verify_mode
  end
end

#format(tag, time, record) ⇒ Object



58
59
60
# File 'lib/fluent/plugin/out_http_file_upload.rb', line 58

def format(tag, time, record)
  @formatter.format(tag, time, record)
end

#write(chunk) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
# File 'lib/fluent/plugin/out_http_file_upload.rb', line 62

def write(chunk)
  filename = Time.now.strftime(@filename)
  chunk.open do |io|
    io.singleton_class.class_eval{ define_method(:path){ filename } }
    postdata = { @param_name => io }
    unless @parameters.empty?
      postdata = @parameters.merge(postdata)
    end
    @client.post(@uri, postdata)
  end
end