Class: Resque::Failure::Mongo

Inherits:
Base
  • Object
show all
Defined in:
lib/resque/failure/mongo.rb

Overview

A Failure backend that stores exceptions in Mongo. Very simple but works out of the box, along with support in the Resque web app.

Instance Attribute Summary

Attributes inherited from Base

#exception, #payload, #queue, #worker

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize, #log, url

Constructor Details

This class inherits a constructor from Resque::Failure::Base

Class Method Details

.all(start = 0, count = 1) ⇒ Object



22
23
24
# File 'lib/resque/failure/mongo.rb', line 22

def self.all(start = 0, count = 1)
  Resque.mongo_failures.find().sort([:natural, :desc]).skip(start).limit(count).to_a
end

.clearObject



26
27
28
# File 'lib/resque/failure/mongo.rb', line 26

def self.clear
  Resque.mongo_failures.remove
end

.countObject



18
19
20
# File 'lib/resque/failure/mongo.rb', line 18

def self.count
  Resque.mongo_failures.count
end

Instance Method Details

#saveObject



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/resque/failure/mongo.rb', line 6

def save
  data = {
    :failed_at => Time.now.strftime("%Y/%m/%d %H:%M:%S"),
    :payload   => payload,
    :error     => exception.to_s,
    :backtrace => exception.backtrace,
    :worker    => worker.to_s,
    :queue     => queue
  }
  Resque.mongo_failures << data
end