class Fluent::IdobataOutput
Public Class Methods
new()
click to toggle source
Calls superclass method
# File lib/fluent/plugin/out_idobata.rb, line 10 def initialize super end
Public Instance Methods
configure(conf)
click to toggle source
Calls superclass method
# File lib/fluent/plugin/out_idobata.rb, line 18 def configure(conf) super @erb = ERB.new(@message_template) @q = Queue.new end
emit(tag, es, chain)
click to toggle source
# File lib/fluent/plugin/out_idobata.rb, line 39 def emit(tag, es, chain) es.each {|time, record| param = OpenStruct.new param.tag = tag param.time = time param.record = record @q.push param } chain.next end
shutdown()
click to toggle source
Calls superclass method
# File lib/fluent/plugin/out_idobata.rb, line 33 def shutdown super Thread.kill(@thread) end
start()
click to toggle source
Calls superclass method
# File lib/fluent/plugin/out_idobata.rb, line 25 def start super @thread = Thread.new(&method(:post)) rescue $log.warn "raises exception: #{$!.class}, '#{$!.message}" end
Private Instance Methods
post()
click to toggle source
# File lib/fluent/plugin/out_idobata.rb, line 54 def post loop do param = @q.pop tag = param.tag time = param.time record = param.record begin HTTParty.post(@webhook_url, :body => "body=#{CGI.escape(@erb.result(binding))}") sleep(@post_interval) rescue $log.warn "raises exception: #{$!.class}, '#{$!.message}, #{param}'" end end end