Class: Logglier::Client::HTTP::DeliveryThreadManager
- Inherits:
-
Object
- Object
- Logglier::Client::HTTP::DeliveryThreadManager
- Defined in:
- lib/logglier/client/http/threaded.rb
Overview
Used by the Threaded client to manage the delivery thread recreating it if is lost due to a fork.
Instance Method Summary collapse
-
#deliver(message) ⇒ Object
Pushes a message to the delivery thread, starting one if necessary.
-
#initialize(input_uri, opts = {}) ⇒ DeliveryThreadManager
constructor
A new instance of DeliveryThreadManager.
Constructor Details
#initialize(input_uri, opts = {}) ⇒ DeliveryThreadManager
Returns a new instance of DeliveryThreadManager.
11 12 13 14 |
# File 'lib/logglier/client/http/threaded.rb', line 11 def initialize(input_uri, opts={}) @input_uri, @opts = input_uri, opts start_thread end |
Instance Method Details
#deliver(message) ⇒ Object
Pushes a message to the delivery thread, starting one if necessary
17 18 19 20 21 22 23 24 25 |
# File 'lib/logglier/client/http/threaded.rb', line 17 def deliver() start_thread unless @thread.alive? @thread.deliver() #Race condition? Sometimes we need to rescue this and start a new thread rescue NoMethodError @thread.kill #Try not to leak threads, should already be dead anyway start_thread retry end |