class Airbrake::AsyncSender
@since v1.0.0
@api private
@see SyncSender
Responsible for sending notices to Airbrake asynchronously.
def close
-
(void)
-
def close @sync_sender.close thread_pool.close end
def closed?
-
(Boolean)
-
def closed? thread_pool.closed? end
def has_workers?
-
(Boolean)
-
def has_workers? thread_pool.has_workers? end
def initialize(method = :post, name = 'async-sender')
def initialize(method = :post, name = 'async-sender') @config = Airbrake::Config.instance @sync_sender = SyncSender.new(method) @name = name end
def send(data, promise, endpoint = @config.error_endpoint)
-
(Airbrake::Promise)
-
Parameters:
-
endpoint
(URI
) -- Where to send +data+ -
promise
(Airbrake::Promise
) -- -
data
(Airbrake::Notice
) -- Whatever needs to be sent
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
def thread_pool
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