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.
11 12 13 14 15 16 17 |
# 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 |
Instance Method Details
#deliver(message) ⇒ Object
Pushes a message to the delivery thread, starting one if necessary
20 21 22 23 24 25 26 27 28 |
# File 'lib/cloudwatchlogger/client/aws_sdk/threaded.rb', line 20 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 |