Class: Rollbar::Delay::Thread

Inherits:
Object
  • Object
show all
Defined in:
lib/rollbar/delay/thread.rb

Constant Summary collapse

EXIT_SIGNAL =
:exit
EXIT_TIMEOUT =
6
Error =
Class.new(StandardError)
TimeoutError =
Class.new(Error)
DEFAULT_PRIORITY =
1

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.optionsObject



26
27
28
# File 'lib/rollbar/delay/thread.rb', line 26

def options
  @options || {}
end

.reaperObject (readonly)

Returns the value of attribute reaper.



16
17
18
# File 'lib/rollbar/delay/thread.rb', line 16

def reaper
  @reaper
end

Class Method Details

.call(payload) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/rollbar/delay/thread.rb', line 18

def call(payload)
  spawn_threads_reaper

  thread = new.call(payload)
  threads << thread
  thread
end

Instance Method Details

#call(payload) ⇒ Object



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# 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

#priorityObject



72
73
74
# File 'lib/rollbar/delay/thread.rb', line 72

def priority
  self.class.options[:priority] || DEFAULT_PRIORITY
end