Class: CloudWatchLogger::Client::AWS_SDK::DeliveryThreadManager

Inherits:
Object
  • Object
show all
Defined in:
lib/cloudwatchlogger/client/aws_sdk/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(credentials, log_group_name, log_stream_name, opts = {}) ⇒ DeliveryThreadManager

Returns a new instance of DeliveryThreadManager.



12
13
14
15
# File 'lib/cloudwatchlogger/client/aws_sdk/threaded.rb', line 12

def initialize(credentials, log_group_name, log_stream_name, opts={})
  @credentials, @log_group_name, @log_stream_name, @opts = credentials, log_group_name, log_stream_name, opts
  start_thread
end

Instance Method Details

#deliver(message) ⇒ Object

Pushes a message to the delivery thread, starting one if necessary



18
19
20
21
22
23
24
25
26
# File 'lib/cloudwatchlogger/client/aws_sdk/threaded.rb', line 18

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