class Airbrake::AsyncSender
Responsible for sending notices to Airbrake
asynchronously.
@see SyncSender
@api private @since v1.0.0
Public Class Methods
new(method = :post, name = 'async-sender')
click to toggle source
# File lib/airbrake-ruby/async_sender.rb, line 8 def initialize(method = :post, name = 'async-sender') @config = Airbrake::Config.instance @sync_sender = SyncSender.new(method) @name = name end
Public Instance Methods
close()
click to toggle source
@return [void]
# File lib/airbrake-ruby/async_sender.rb, line 31 def close @sync_sender.close thread_pool.close end
closed?()
click to toggle source
@return [Boolean]
# File lib/airbrake-ruby/async_sender.rb, line 37 def closed? thread_pool.closed? end
has_workers?()
click to toggle source
@return [Boolean]
# File lib/airbrake-ruby/async_sender.rb, line 42 def has_workers? thread_pool.has_workers? end
send(data, promise, endpoint = @config.error_endpoint)
click to toggle source
Asynchronously sends a notice to Airbrake
.
@param [Airbrake::Notice] data Whatever needs to be sent @param [Airbrake::Promise] promise @param [URI] endpoint Where to send data
@return [Airbrake::Promise]
# File lib/airbrake-ruby/async_sender.rb, line 20 def send(data, promise, endpoint = @config.error_endpoint) unless thread_pool << [data, promise, endpoint] return promise.reject( "AsyncSender has reached its capacity of #{@config.queue_size}", ) end promise end
Private Instance Methods
thread_pool()
click to toggle source
# File lib/airbrake-ruby/async_sender.rb, line 48 def thread_pool @thread_pool ||= ThreadPool.new( name: @name, worker_size: @config.workers, queue_size: @config.queue_size, block: proc { |args| @sync_sender.send(*args) }, ) end