Class: Bugsnag::Delivery::ThreadQueue

Inherits:
Synchronous show all
Defined in:
lib/bugsnag/delivery/thread_queue.rb

Constant Summary collapse

MAX_OUTSTANDING_REQUESTS =
100
STOP =
Object.new
MUTEX =
Mutex.new

Class Method Summary collapse

Class Method Details

.serialize_and_deliver(url, get_payload, configuration, options = {}) ⇒ void

This method returns an undefined value.

Queues a given payload to be delivered asynchronously

Parameters:

  • url (String)
  • get_payload (Proc)

    A Proc that will return the payload.

  • configuration (Bugsnag::Configuration)
  • options (Hash) (defaults to: {})


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/bugsnag/delivery/thread_queue.rb', line 17

def serialize_and_deliver(url, get_payload, configuration, options={})
  @configuration = configuration

  start_once!

  if @queue.length > MAX_OUTSTANDING_REQUESTS
    @configuration.warn("Dropping notification, #{@queue.length} outstanding requests")
    return
  end

  # Add delivery to the worker thread
  @queue.push(proc do
    begin
      payload = get_payload.call
    rescue StandardError => e
      configuration.error("Unable to send information to Bugsnag (#{url}), #{e.inspect}")
      configuration.error(e.backtrace)
    end

    Synchronous.deliver(url, payload, configuration, options) unless payload.nil?
  end)
end