Class: Resque::Failure::Mongo
- Inherits:
-
Base
- Object
- Base
- Resque::Failure::Mongo
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
Class Method Details
.all(start = 0, count = 1) ⇒ Object
23
24
25
26
27
|
# File 'lib/resque/failure/mongo.rb', line 23
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
|
.clear ⇒ Object
29
30
31
|
# File 'lib/resque/failure/mongo.rb', line 29
def self.clear
Resque.mongo_failures.remove
end
|
.count ⇒ Object
19
20
21
|
# File 'lib/resque/failure/mongo.rb', line 19
def self.count
Resque.mongo_failures.count
end
|
.requeue(index) ⇒ Object
33
34
35
36
37
38
|
# File 'lib/resque/failure/mongo.rb', line 33
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
|
Instance Method Details
#save ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/resque/failure/mongo.rb', line 6
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
|