class Fluent::HRForecastOutput::PostThread

Attributes

queue[R]

Public Class Methods

new(plugin) click to toggle source
# File lib/fluent/plugin/out_hrforecast.rb, line 99
def initialize(plugin)
  require 'thread'
  @queue = Queue.new
  @plugin = plugin
  @thread = Thread.new do
    begin
      post(@queue.deq) while true
    ensure
      post(@queue.deq) while not @queue.empty?
    end
  end
end

Public Instance Methods

post(events) click to toggle source
# File lib/fluent/plugin/out_hrforecast.rb, line 112
def post(events)
  begin
    @plugin.post_events(events) if events.size > 0
  rescue => e
    @plugin.log.warn "HTTP POST in background Error occures to HRforecast server", :error_class => e.class, :error => e.message
  end
end
shutdown() click to toggle source
# File lib/fluent/plugin/out_hrforecast.rb, line 120
def shutdown
  @thread.terminate
  @thread.join
end