Sha256: ba6ea17868998004e65b24a0b15a106ccab196a6231cedc1c87c838b22bad409

Contents?: true

Size: 1.29 KB

Versions: 46

Compression:

Stored size: 1.29 KB

Contents

module Resque
  module Failure
    # A Failure backend that stores exceptions in Mongo. Very simple but
    # works out of the box, along with support in the Resque web app.
    class Mongo < Base
      def save
        data = {
          :failed_at => Time.now.strftime("%Y/%m/%d %H:%M:%S"),
          :payload   => payload,
          :exception => exception.class.to_s,
          :error     => exception.to_s,
          :backtrace => Array(exception.backtrace),
          :worker    => worker.to_s,
          :queue     => queue
        }
        Resque.mongo_failures << data
      end

      def self.count
        Resque.mongo_failures.count
      end

      def self.all(start = 0, count = 1)
        start, count = [start, count].map { |n| Integer(n) }
        all_failures = Resque.mongo_failures.find().sort([:natural, :desc]).skip(start).limit(count).to_a
        all_failures.size == 1 ? all_failures.first : all_failures
      end

      def self.clear
        Resque.mongo_failures.remove
      end

      def self.requeue(index)
        item = all(index)
        item['retried_at'] = Time.now.strftime("%Y/%m/%d %H:%M:%S")
        Resque.mongo_failures.update({:_id => item['_id']}, item)
        Job.create(item['queue'], item['payload']['class'], *item['payload']['args'])
      end
    end
  end
end

Version data entries

46 entries across 46 versions & 2 rubygems

Version Path
classiccms-0.7.5 vendor/bundle/gems/resque-mongo-1.9.8.1/lib/resque/failure/mongo.rb
classiccms-0.7.4 vendor/bundle/gems/resque-mongo-1.9.8.1/lib/resque/failure/mongo.rb
classiccms-0.7.3 vendor/bundle/gems/resque-mongo-1.9.8.1/lib/resque/failure/mongo.rb
classiccms-0.7.2 vendor/bundle/gems/resque-mongo-1.9.8.1/lib/resque/failure/mongo.rb
classiccms-0.7.1 vendor/bundle/gems/resque-mongo-1.9.8.1/lib/resque/failure/mongo.rb
classiccms-0.7.0 vendor/bundle/gems/resque-mongo-1.9.8.1/lib/resque/failure/mongo.rb
classiccms-0.6.9 vendor/bundle/gems/resque-mongo-1.9.8.1/lib/resque/failure/mongo.rb
classiccms-0.6.8 vendor/bundle/gems/resque-mongo-1.9.8.1/lib/resque/failure/mongo.rb
classiccms-0.6.7 vendor/bundle/gems/resque-mongo-1.9.8.1/lib/resque/failure/mongo.rb
classiccms-0.6.6 vendor/bundle/gems/resque-mongo-1.9.8.1/lib/resque/failure/mongo.rb
classiccms-0.6.5 vendor/bundle/gems/resque-mongo-1.9.8.1/lib/resque/failure/mongo.rb
classiccms-0.6.4 vendor/bundle/gems/resque-mongo-1.9.8.1/lib/resque/failure/mongo.rb
classiccms-0.6.3 vendor/bundle/gems/resque-mongo-1.9.8.1/lib/resque/failure/mongo.rb
classiccms-0.6.2 vendor/bundle/gems/resque-mongo-1.9.8.1/lib/resque/failure/mongo.rb
classiccms-0.6.1 vendor/bundle/gems/resque-mongo-1.9.8.1/lib/resque/failure/mongo.rb
classiccms-0.6.0 vendor/bundle/gems/resque-mongo-1.9.8.1/lib/resque/failure/mongo.rb
classiccms-0.5.17 vendor/bundle/gems/resque-mongo-1.9.8.1/lib/resque/failure/mongo.rb
classiccms-0.5.16 vendor/bundle/gems/resque-mongo-1.9.8.1/lib/resque/failure/mongo.rb
classiccms-0.5.15 vendor/bundle/gems/resque-mongo-1.9.8.1/lib/resque/failure/mongo.rb
classiccms-0.5.14 vendor/bundle/gems/resque-mongo-1.9.8.1/lib/resque/failure/mongo.rb