Sha256: d41eae586e1c3b713e5b7ddfc6119cd2f49dc1162226a2332df1776581fe871c

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

require 'shoryuken'

module Rollbar
  module Delay
    # Following class allows to send rollbars using Sho-ryu-ken as a background jobs processor.
    # see the queue_name method which states that your queues needs to be names as "rollbar_ENVIRONMENT".
    # retry intervals will be used to retry sending the same message again if failed before.
    class Shoryuken
      include ::Shoryuken::Worker

      # not allowing bulk, to not double-report rollbars if one of them failed in bunch.
      shoryuken_options :queue => queue_name, :auto_delete => true, :body_parser => :json, :retry_intervals => [60, 180, 360, 120_0, 360_0, 186_00]

      def self.queue_name
        "rollbar_#{Rollbar.configuration.environment}"
      end

      ## responsible for performing job. - payload is a json parsed body of the message.
      def perform(_sqs_message, payload)
        Rollbar.process_from_async_handler(payload)
      end

      ## to push the job !
      def call(payload)
        self.class.perform_async(payload)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rollbar-2.15.1 lib/rollbar/delay/shoryuken.rb