Sha256: 015f9dfafdeb4cb034ca8664c42671ef1c7108a85b3a51db2ec8e5cf0b0c23b0
Contents?: true
Size: 1.12 KB
Versions: 1
Compression:
Stored size: 1.12 KB
Contents
require "thread" module Bugsnag module Delivery class ThreadQueue < Synchronous MAX_OUTSTANDING_REQUESTS = 100 STOP = Object.new class << self def deliver(url, body, configuration) if queue.length > MAX_OUTSTANDING_REQUESTS Bugsnag.warn("Dropping notification, #{queue.length} outstanding requests") return end # Add delivery to the worker thread queue.push proc { super(url, body, configuration) } end private attr_reader :queue def start! @queue = Queue.new worker_thread = Thread.new do while x = queue.pop break if x == STOP x.call end end at_exit do Bugsnag.warn("Waiting for #{queue.length} outstanding request(s)") unless queue.empty? queue.push STOP worker_thread.join end end end # do this once at require time to avoid race conditions start! end end end Bugsnag::Delivery.register(:thread_queue, Bugsnag::Delivery::ThreadQueue)
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bugsnag-2.8.2 | lib/bugsnag/delivery/thread_queue.rb |