class Rollbar::Delay::Thread
Constants
- DEFAULT_PRIORITY
- EXIT_SIGNAL
- EXIT_TIMEOUT
- Error
- TimeoutError
Attributes
options[W]
reaper[R]
Public Class Methods
call(payload)
click to toggle source
# File lib/rollbar/delay/thread.rb, line 18 def call(payload) spawn_threads_reaper thread = new.call(payload) threads << thread thread end
options()
click to toggle source
# File lib/rollbar/delay/thread.rb, line 26 def options @options || {} end
Private Class Methods
build_reaper_thread()
click to toggle source
# File lib/rollbar/delay/thread.rb, line 45 def build_reaper_thread ::Thread.start do loop do thread = threads.pop break if thread == EXIT_SIGNAL thread.join end end end
configure_exit_handler()
click to toggle source
# File lib/rollbar/delay/thread.rb, line 57 def configure_exit_handler at_exit do begin Timeout.timeout(EXIT_TIMEOUT) do threads << EXIT_SIGNAL reaper.join end rescue Timeout::Error raise TimeoutError, "unable to reap all threads within #{EXIT_TIMEOUT} seconds" end end end
spawn_threads_reaper()
click to toggle source
# File lib/rollbar/delay/thread.rb, line 36 def spawn_threads_reaper return if @spawned @spawned = true @reaper ||= build_reaper_thread configure_exit_handler end
threads()
click to toggle source
# File lib/rollbar/delay/thread.rb, line 32 def threads @threads ||= Queue.new end
Public Instance Methods
call(payload)
click to toggle source
# File lib/rollbar/delay/thread.rb, line 76 def call(payload) priority = self.priority ::Thread.new do begin ::Thread.current.priority = priority Rollbar.process_from_async_handler(payload) rescue StandardError # Here we swallow the exception: # 1. The original report wasn't sent. # 2. An internal error was sent and logged # # If users want to handle this in some way they # can provide a more custom Thread based implementation end end end
priority()
click to toggle source
# File lib/rollbar/delay/thread.rb, line 72 def priority self.class.options[:priority] || DEFAULT_PRIORITY end