resque-history 1.8.2 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Changelog.md +7 -1
- data/README.md +3 -1
- data/VERSION +1 -1
- data/lib/resque-history/plugins/history.rb +14 -0
- data/lib/resque-history/server/views/history.erb +33 -19
- data/resque-history.gemspec +2 -2
- data/spec/resque-history/plugins/history_spec.rb +28 -0
- metadata +2 -2
data/Changelog.md
CHANGED
data/README.md
CHANGED
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.
|
|
1
|
+
1.9.0
|
|
@@ -9,6 +9,20 @@ module Resque
|
|
|
9
9
|
@max_history ||= MAX_HISTORY_SIZE
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
+
def on_failure_history(exception, *args)
|
|
13
|
+
Resque.redis.lpush(HISTORY_SET_NAME, {"class"=>"#{self}",
|
|
14
|
+
"time"=>Time.now.strftime("%Y-%m-%d %H:%M"),
|
|
15
|
+
"args"=>args,
|
|
16
|
+
"error"=>exception.message
|
|
17
|
+
}.to_json)
|
|
18
|
+
|
|
19
|
+
if Resque.redis.llen(HISTORY_SET_NAME) > maximum_history_size
|
|
20
|
+
Resque.redis.rpop(HISTORY_SET_NAME)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
|
|
12
26
|
def before_perform_hsitory(*args)
|
|
13
27
|
@start_time = Time.now
|
|
14
28
|
end
|
|
@@ -11,25 +11,39 @@
|
|
|
11
11
|
<% end %>
|
|
12
12
|
|
|
13
13
|
<p class='intro'>Showing <%=start%> to <%= start + 20 %> of <b><%= size = Resque.redis.llen(Resque::Plugins::History::HISTORY_SET_NAME) %></b> jobs</p>
|
|
14
|
+
<div id="main">
|
|
15
|
+
<%= partial :next_more, :start => params[:start].to_i, :size => size %>
|
|
14
16
|
|
|
15
|
-
|
|
17
|
+
<table>
|
|
18
|
+
<tr>
|
|
19
|
+
<th>Job</th>
|
|
20
|
+
<th>Arguments</th>
|
|
21
|
+
<th>Time</th>
|
|
22
|
+
<th>Execution</th>
|
|
23
|
+
</tr>
|
|
24
|
+
<% history.each do |history| %>
|
|
25
|
+
<% j = JSON.parse(history) %>
|
|
26
|
+
<tr class='<%= j["error"].nil? ? "" : "failure" %>' >
|
|
27
|
+
<td class='queue'><%= j["class"] %></td>
|
|
28
|
+
<td class='args'><%= j["args"] %></td>
|
|
29
|
+
<td class='args'><%= j["time"] %></td>
|
|
30
|
+
<td class='args'><%= format_execution(j["execution"]) %></td>
|
|
31
|
+
</tr>
|
|
32
|
+
<% end %>
|
|
33
|
+
</table>
|
|
16
34
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
<th>Job</th>
|
|
20
|
-
<th>Arguments</th>
|
|
21
|
-
<th>Time</th>
|
|
22
|
-
<th>Execution</th>
|
|
23
|
-
</tr>
|
|
24
|
-
<% history.each do |history| %>
|
|
25
|
-
<% j = JSON.parse(history) %>
|
|
26
|
-
<tr>
|
|
27
|
-
<td class='queue'><%= j["class"] %></td>
|
|
28
|
-
<td class='args'><%= j["args"] %></td>
|
|
29
|
-
<td class='args'><%= j["time"] %></td>
|
|
30
|
-
<td class='args'><%= format_execution(j["execution"]) %></td>
|
|
31
|
-
</tr>
|
|
32
|
-
<% end %>
|
|
33
|
-
</table>
|
|
35
|
+
<%= partial :next_more, :start => start, :size => size %>
|
|
36
|
+
</div>
|
|
34
37
|
|
|
35
|
-
|
|
38
|
+
<style type="text/css">
|
|
39
|
+
#main table tr.failure td {
|
|
40
|
+
background: #ffecec;
|
|
41
|
+
border-top: 2px solid #d37474;
|
|
42
|
+
font-size: 90%;
|
|
43
|
+
color: #d37474;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
#main table tr.failure td a {
|
|
47
|
+
color: #d37474;
|
|
48
|
+
}
|
|
49
|
+
</style>
|
data/resque-history.gemspec
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |s|
|
|
7
7
|
s.name = "resque-history"
|
|
8
|
-
s.version = "1.
|
|
8
|
+
s.version = "1.9.0"
|
|
9
9
|
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
11
|
s.authors = ["Katzmopolitan"]
|
|
12
|
-
s.date = "2012-05-
|
|
12
|
+
s.date = "2012-05-09"
|
|
13
13
|
s.description = "Show history of recently executed jobs"
|
|
14
14
|
s.email = "ilyakatz@gmail.com"
|
|
15
15
|
s.extra_rdoc_files = [
|
|
@@ -19,6 +19,7 @@ class MaxHistoryJob
|
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
describe Resque::Plugins::History do
|
|
22
|
+
|
|
22
23
|
it "should be compliance with Resqu::Plugin document" do
|
|
23
24
|
expect { Resque::Plugin.lint(Resque::Plugins::History) }.to_not raise_error
|
|
24
25
|
end
|
|
@@ -171,6 +172,24 @@ describe Resque::Plugins::History do
|
|
|
171
172
|
|
|
172
173
|
end
|
|
173
174
|
|
|
175
|
+
it "should record failed jobs" do
|
|
176
|
+
|
|
177
|
+
Resque.enqueue(ExceptionJob,"nothing")
|
|
178
|
+
|
|
179
|
+
job = Resque.reserve('test')
|
|
180
|
+
|
|
181
|
+
lambda { job.perform }.should raise_exception
|
|
182
|
+
arr = Resque.redis.lrange(Resque::Plugins::History::HISTORY_SET_NAME, 0, -1)
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
arr.count.should == 1
|
|
186
|
+
|
|
187
|
+
JSON.parse(arr.first)["class"].should =="ExceptionJob"
|
|
188
|
+
JSON.parse(arr.first)["args"].should == ["nothing"]
|
|
189
|
+
JSON.parse(arr.first)["execution"].should == nil
|
|
190
|
+
JSON.parse(arr.first)["error"].should == "I'm an error"
|
|
191
|
+
end
|
|
192
|
+
|
|
174
193
|
end
|
|
175
194
|
|
|
176
195
|
end
|
|
@@ -192,3 +211,12 @@ class SleepyHistoryJob
|
|
|
192
211
|
sleep(time_in_seconds)
|
|
193
212
|
end
|
|
194
213
|
end
|
|
214
|
+
|
|
215
|
+
class ExceptionJob
|
|
216
|
+
extend Resque::Plugins::History
|
|
217
|
+
@queue = :test
|
|
218
|
+
|
|
219
|
+
def self.perform(arg)
|
|
220
|
+
raise StandardError, "I'm an error"
|
|
221
|
+
end
|
|
222
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: resque-history
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.9.0
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2012-05-
|
|
12
|
+
date: 2012-05-09 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: resque-history
|