Class: CloudWatchLogger::Client::AWS_SDK::DeliveryThreadManager
- Inherits:
-
Object
- Object
- CloudWatchLogger::Client::AWS_SDK::DeliveryThreadManager
- 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
-
#deliver(message) ⇒ Object
Pushes a message to the delivery thread, starting one if necessary.
-
#initialize(credentials, log_group_name, log_stream_name, opts = {}) ⇒ DeliveryThreadManager
constructor
A new instance of DeliveryThreadManager.
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() 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 |