Class: Fluent::HRForecastOutput::PostThread
- Inherits:
-
Object
- Object
- Fluent::HRForecastOutput::PostThread
- Defined in:
- lib/fluent/plugin/out_hrforecast.rb
Instance Attribute Summary collapse
-
#queue ⇒ Object
readonly
Returns the value of attribute queue.
Instance Method Summary collapse
-
#initialize(plugin) ⇒ PostThread
constructor
A new instance of PostThread.
- #post(events) ⇒ Object
- #shutdown ⇒ Object
Constructor Details
#initialize(plugin) ⇒ PostThread
Returns a new instance of PostThread.
99 100 101 102 103 104 105 106 107 108 109 110 |
# 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 |
Instance Attribute Details
#queue ⇒ Object (readonly)
Returns the value of attribute queue.
97 98 99 |
# File 'lib/fluent/plugin/out_hrforecast.rb', line 97 def queue @queue end |
Instance Method Details
#post(events) ⇒ Object
112 113 114 115 116 117 118 |
# 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. end end |
#shutdown ⇒ Object
120 121 122 123 |
# File 'lib/fluent/plugin/out_hrforecast.rb', line 120 def shutdown @thread.terminate @thread.join end |