Class: Logglier::Client::HTTP::DeliveryThreadManager

Inherits:
Object
  • Object
show all
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

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(message)
  start_thread unless @thread.alive?
  @thread.deliver(message)
  #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