resque-cleaner 0.2.6 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +5 -0
- data/README.markdown +2 -2
- data/lib/resque_cleaner/server.rb +5 -1
- data/lib/resque_cleaner.rb +7 -3
- data/test/resque_cleaner_test.rb +6 -0
- data/test/test_helper.rb +14 -0
- metadata +32 -53
data/CHANGELOG.md
CHANGED
data/README.markdown
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
ResqueCleaner
|
1
|
+
ResqueCleaner [ ![Travis-CI](https://secure.travis-ci.org/ono/resque-cleaner.png?branch=master "Travis CI") ](http://travis-ci.org/ono/resque-cleaner "Travis CI for resque-cleaner")
|
2
2
|
==============
|
3
3
|
|
4
4
|
[github.com/ono/resque-cleaner](https://github.com/ono/resque-cleaner)
|
@@ -264,7 +264,7 @@ You could know if the limiter is on with on? method.
|
|
264
264
|
You can change the maximum number of the limiter with maximum attribute.
|
265
265
|
|
266
266
|
```ruby
|
267
|
-
> cleaner.limiter.
|
267
|
+
> cleaner.limiter.maximum = 3000
|
268
268
|
=> 3,000
|
269
269
|
> cleaner.limiter.count
|
270
270
|
=> 3,000
|
@@ -108,7 +108,11 @@ module ResqueCleaner
|
|
108
108
|
@jobs = cleaner.select
|
109
109
|
@stats, @total = {}, {"total" => 0, "1h" => 0, "3h" => 0, "1d" => 0, "3d" => 0, "7d" => 0}
|
110
110
|
@jobs.each do |job|
|
111
|
-
klass = job["payload"]["class"]
|
111
|
+
klass = if job["payload"] && job["payload"]["class"]
|
112
|
+
job["payload"]["class"]
|
113
|
+
else
|
114
|
+
"UNKNOWN"
|
115
|
+
end
|
112
116
|
failed_at = Time.parse job["failed_at"]
|
113
117
|
|
114
118
|
@stats[klass] ||= {"total" => 0, "1h" => 0, "3h" => 0, "1d" => 0, "3d" => 0, "7d" => 0}
|
data/lib/resque_cleaner.rb
CHANGED
@@ -53,7 +53,7 @@ module Resque
|
|
53
53
|
def stats_by_class(&block)
|
54
54
|
jobs, stats = select(&block), {}
|
55
55
|
jobs.each do |job|
|
56
|
-
klass = job["payload"]["class"]
|
56
|
+
klass = job["payload"] && job["payload"]["class"] ? job["payload"]["class"] : "UNKNOWN"
|
57
57
|
stats[klass] ||= 0
|
58
58
|
stats[klass] += 1
|
59
59
|
end
|
@@ -171,7 +171,11 @@ module Resque
|
|
171
171
|
|
172
172
|
# Returns true if the class of the job matches. Otherwise returns false.
|
173
173
|
def klass?(klass_or_name)
|
174
|
-
self["payload"]["class"]
|
174
|
+
if self["payload"] && self["payload"]["class"]
|
175
|
+
self["payload"]["class"] == klass_or_name.to_s
|
176
|
+
else
|
177
|
+
klass_or_name=="UNKNOWN"
|
178
|
+
end
|
175
179
|
end
|
176
180
|
|
177
181
|
# Returns true if the exception raised by the failed job matches. Otherwise returns false.
|
@@ -211,7 +215,7 @@ module Resque
|
|
211
215
|
end
|
212
216
|
end
|
213
217
|
|
214
|
-
# Returns jobs. If numbers of jobs is more than
|
218
|
+
# Returns jobs. If numbers of jobs is more than maximum, it returns only
|
215
219
|
# the maximum.
|
216
220
|
def jobs
|
217
221
|
if @locked
|
data/test/resque_cleaner_test.rb
CHANGED
@@ -153,6 +153,12 @@ context "ResqueCleaner" do
|
|
153
153
|
assert_equal 7, ret['BadJobWithSyntaxError']
|
154
154
|
end
|
155
155
|
|
156
|
+
test "#stats_by_class works with broken log" do
|
157
|
+
add_empty_payload_failure
|
158
|
+
ret = @cleaner.stats_by_class
|
159
|
+
assert_equal 1, ret['UNKNOWN']
|
160
|
+
end
|
161
|
+
|
156
162
|
test "#stats_by_exception returns stats grouped by exception" do
|
157
163
|
ret = @cleaner.stats_by_exception
|
158
164
|
assert_equal 35, ret['RuntimeError']
|
data/test/test_helper.rb
CHANGED
@@ -137,3 +137,17 @@ end
|
|
137
137
|
def queue_size(*queues)
|
138
138
|
queues.inject(0){|sum,queue| sum + Resque.size(queue).to_i}
|
139
139
|
end
|
140
|
+
|
141
|
+
def add_empty_payload_failure
|
142
|
+
data = {
|
143
|
+
:failed_at => Time.now.strftime("%Y/%m/%d %H:%M:%S %Z"),
|
144
|
+
:payload => nil,
|
145
|
+
:exception => "Resque::DirtyExit",
|
146
|
+
:error => "Resque::DirtyExit",
|
147
|
+
:backtrace => [],
|
148
|
+
:worker => "worker",
|
149
|
+
:queue => "queue"
|
150
|
+
}
|
151
|
+
data = Resque.encode(data)
|
152
|
+
Resque.redis.rpush(:failed, data)
|
153
|
+
end
|
metadata
CHANGED
@@ -1,49 +1,38 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: resque-cleaner
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 2
|
9
|
-
- 6
|
10
|
-
version: 0.2.6
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.7
|
5
|
+
prerelease:
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Tatsuya Ono
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-01-17 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
22
15
|
name: resque
|
23
|
-
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &70281247431200 !ruby/object:Gem::Requirement
|
25
17
|
none: false
|
26
|
-
requirements:
|
18
|
+
requirements:
|
27
19
|
- - ~>
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
segments:
|
31
|
-
- 1
|
32
|
-
- 0
|
33
|
-
version: "1.0"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.0'
|
34
22
|
type: :runtime
|
35
|
-
|
36
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70281247431200
|
25
|
+
description: ! ' resque-cleaner maintains the cleanliness of failed jobs on Resque.
|
26
|
+
|
27
|
+
'
|
37
28
|
email: ononoma@gmail.com
|
38
29
|
executables: []
|
39
|
-
|
40
30
|
extensions: []
|
41
|
-
|
42
|
-
extra_rdoc_files:
|
31
|
+
extra_rdoc_files:
|
43
32
|
- LICENSE
|
44
33
|
- README.markdown
|
45
34
|
- CHANGELOG.md
|
46
|
-
files:
|
35
|
+
files:
|
47
36
|
- README.markdown
|
48
37
|
- CHANGELOG.md
|
49
38
|
- Rakefile
|
@@ -61,39 +50,29 @@ files:
|
|
61
50
|
- test/resque_cleaner_test.rb
|
62
51
|
- test/resque_web_test.rb
|
63
52
|
- test/test_helper.rb
|
64
|
-
has_rdoc: true
|
65
53
|
homepage: http://github.com/ono/resque-cleaner
|
66
54
|
licenses: []
|
67
|
-
|
68
55
|
post_install_message:
|
69
|
-
rdoc_options:
|
56
|
+
rdoc_options:
|
70
57
|
- --charset=UTF-8
|
71
|
-
require_paths:
|
58
|
+
require_paths:
|
72
59
|
- lib
|
73
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
74
61
|
none: false
|
75
|
-
requirements:
|
76
|
-
- -
|
77
|
-
- !ruby/object:Gem::Version
|
78
|
-
|
79
|
-
|
80
|
-
- 0
|
81
|
-
version: "0"
|
82
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
67
|
none: false
|
84
|
-
requirements:
|
85
|
-
- -
|
86
|
-
- !ruby/object:Gem::Version
|
87
|
-
|
88
|
-
segments:
|
89
|
-
- 0
|
90
|
-
version: "0"
|
68
|
+
requirements:
|
69
|
+
- - ! '>='
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
91
72
|
requirements: []
|
92
|
-
|
93
73
|
rubyforge_project:
|
94
|
-
rubygems_version: 1.
|
74
|
+
rubygems_version: 1.8.11
|
95
75
|
signing_key:
|
96
76
|
specification_version: 3
|
97
77
|
summary: Resque plugin cleaning up failed jobs.
|
98
78
|
test_files: []
|
99
|
-
|