Sha256: 81cbca2e26f5a3bbd2ff8c43f8205997f5820064c9327e94957b71465ac6be94

Contents?: true

Size: 1.31 KB

Versions: 8

Compression:

Stored size: 1.31 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

        self.perform_proc = if major_version > 1
                              proc { |payload| perform_async(payload) }
                            else
                              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)
        Rollbar.process_from_async_handler(*args)
      rescue StandardError
        # 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

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rollbar-2.22.1 lib/rollbar/delay/sucker_punch.rb
rollbar-2.22.0 lib/rollbar/delay/sucker_punch.rb
rollbar-2.21.0 lib/rollbar/delay/sucker_punch.rb
rollbar-2.20.2 lib/rollbar/delay/sucker_punch.rb
rollbar-2.20.1 lib/rollbar/delay/sucker_punch.rb
rollbar-2.20.0 lib/rollbar/delay/sucker_punch.rb
rollbar-2.19.4 lib/rollbar/delay/sucker_punch.rb
rollbar-2.19.3 lib/rollbar/delay/sucker_punch.rb