Class: Rollbar::Delay::SuckerPunch

Inherits:
Object
  • Object
show all
Includes:
SuckerPunch::Job
Defined in:
lib/rollbar/delay/sucker_punch.rb

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.perform_procObject

Returns the value of attribute perform_proc.



10
11
12
# File 'lib/rollbar/delay/sucker_punch.rb', line 10

def perform_proc
  @perform_proc
end

.readyObject

Returns the value of attribute ready.



11
12
13
# File 'lib/rollbar/delay/sucker_punch.rb', line 11

def ready
  @ready
end

Class Method Details

.call(payload) ⇒ Object



28
29
30
31
32
# File 'lib/rollbar/delay/sucker_punch.rb', line 28

def self.call(payload)
  setup unless ready

  perform_proc.call(payload)
end

.setupObject



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/rollbar/delay/sucker_punch.rb', line 16

def self.setup
  major_version = ::SuckerPunch::VERSION.split.first.to_i

  if major_version > 1
    self.perform_proc = proc { |payload| perform_async(payload) }
  else
    self.perform_proc = proc { |payload| new.async.perform(payload) }
  end

  self.ready = true
end

Instance Method Details

#perform(*args) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/rollbar/delay/sucker_punch.rb', line 34

def perform(*args)
  begin
    Rollbar.process_from_async_handler(*args)
  rescue
    # SuckerPunch can configure an exception handler with:
    #
    # SuckerPunch.exception_handler { # do something here }
    #
    # This is just passed to Celluloid.exception_handler which will
    # push the reiceved block to an array of handlers, by default empty, [].
    #
    # We reraise the exception here casue it's safe and users could have defined
    # their own exception handler for SuckerPunch
    raise
  end
end