class CloudWatchLogger::Client::AWS_SDK::DeliveryThreadManager

Used by the Threaded client to manage the delivery thread recreating it if is lost due to a fork.

Public Class Methods

new(credentials, log_group_name, log_stream_name, opts = {}) click to toggle source
# File lib/cloudwatchlogger/client/aws_sdk/threaded.rb, line 11
def initialize(credentials, log_group_name, log_stream_name, opts = {})
  @credentials = credentials
  @log_group_name = log_group_name
  @log_stream_name = log_stream_name
  @opts = opts
  start_thread
end

Public Instance Methods

deliver(message) click to toggle source

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

# File lib/cloudwatchlogger/client/aws_sdk/threaded.rb, line 20
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

Private Instance Methods

start_thread() click to toggle source
# File lib/cloudwatchlogger/client/aws_sdk/threaded.rb, line 32
def start_thread
  @thread = DeliveryThread.new(@credentials, @log_group_name, @log_stream_name, @opts)
end