Sha256: 2b4552ed398ec3e03722ec480a25e48e83f6b08b213678a02f5dac819f5da0e6

Contents?: true

Size: 1.29 KB

Versions: 19

Compression:

Stored size: 1.29 KB

Contents

require 'sucker_punch'
require 'sucker_punch/version'

module Rollbar
  module Delay
    class SuckerPunch

      include ::SuckerPunch::Job

      class << self
        attr_accessor :perform_proc
        attr_accessor :ready
      end

      self.ready = false

      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

      def self.call(payload)
        setup unless ready

        perform_proc.call(payload)
      end

      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
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
rollbar-2.14.1 lib/rollbar/delay/sucker_punch.rb
rollbar-2.14.0 lib/rollbar/delay/sucker_punch.rb
rollbar-2.13.3 lib/rollbar/delay/sucker_punch.rb
rollbar-2.13.2 lib/rollbar/delay/sucker_punch.rb
rollbar-2.13.1 lib/rollbar/delay/sucker_punch.rb
rollbar-2.13.0 lib/rollbar/delay/sucker_punch.rb
rollbar-2.12.0 lib/rollbar/delay/sucker_punch.rb
rollbar-2.11.5 lib/rollbar/delay/sucker_punch.rb
rollbar-2.11.4 lib/rollbar/delay/sucker_punch.rb
rollbar-2.11.3 lib/rollbar/delay/sucker_punch.rb
rollbar-2.11.2 lib/rollbar/delay/sucker_punch.rb
rollbar-2.11.1 lib/rollbar/delay/sucker_punch.rb
rollbar-2.11.0 lib/rollbar/delay/sucker_punch.rb
rollbar-2.10.0 lib/rollbar/delay/sucker_punch.rb
rollbar-2.9.1 lib/rollbar/delay/sucker_punch.rb
rollbar-2.9.0 lib/rollbar/delay/sucker_punch.rb
rollbar-2.8.3 lib/rollbar/delay/sucker_punch.rb
rollbar-2.8.2 lib/rollbar/delay/sucker_punch.rb
rollbar-2.8.1 lib/rollbar/delay/sucker_punch.rb