resque-igo 1.1.3 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/resque.rb +1 -0
- data/lib/resque/failure/mongo.rb +0 -1
- data/lib/resque/server.rb +7 -0
- data/lib/resque/server/public/style.css +6 -4
- data/lib/resque/server/views/queues.erb +6 -2
- data/lib/resque/version.rb +1 -1
- data/test/resque_test.rb +7 -7
- data/test/worker_test.rb +4 -2
- metadata +4 -4
data/lib/resque.rb
CHANGED
@@ -165,6 +165,7 @@ module Resque
|
|
165
165
|
# Pushes a job onto a queue. Queue name should be a string and the
|
166
166
|
# item should be any JSON-able Ruby object.
|
167
167
|
def push(queue, item)
|
168
|
+
item[:resque_enqueue_timestamp] = Time.now
|
168
169
|
if item[:unique]
|
169
170
|
mongo[queue].update({'_id' => item[:_id]}, item, { :upsert => true})
|
170
171
|
else
|
data/lib/resque/failure/mongo.rb
CHANGED
data/lib/resque/server.rb
CHANGED
@@ -110,6 +110,13 @@ module Resque
|
|
110
110
|
return "Immediately (#{time})" if now > delay_until
|
111
111
|
return time
|
112
112
|
end
|
113
|
+
|
114
|
+
def enqueued_at(resque_enqueue_timestamp)
|
115
|
+
return 'Unknown' if resque_enqueue_timestamp.nil?
|
116
|
+
now = Time.now
|
117
|
+
time = distance_of_time_in_words(now, resque_enqueue_timestamp)
|
118
|
+
return time
|
119
|
+
end
|
113
120
|
|
114
121
|
def distance_of_time_in_words(from_time, to_time = 0, include_seconds = true, options = {})
|
115
122
|
from_time = from_time.to_time if from_time.respond_to?(:to_time)
|
@@ -37,12 +37,14 @@ body { padding:0; margin:0; }
|
|
37
37
|
#main table.queues tr.failure td { background:#ffecec; border-top:2px solid #d37474; font-size:90%; color:#d37474;}
|
38
38
|
#main table.queues tr.failure td a{ color:#d37474;}
|
39
39
|
|
40
|
-
#main table.jobs td.class { font-family:Monaco, "Courier New", monospace; font-size:90%; width:
|
41
|
-
#main table.jobs td.args{ width:50%;}
|
40
|
+
#main table.jobs td.class { font-family:Monaco, "Courier New", monospace; font-size:90%; width:30%;}
|
41
|
+
#main table.jobs td.args{ width:50%;word-break:break-word;}
|
42
|
+
#main table.jobs td.enqueuedat{ width:20%;}
|
42
43
|
|
43
44
|
#main table.delays td.class { font-family:Monaco, "Courier New", monospace; font-size:90%; width:20%;}
|
44
|
-
#main table.delays td.args{ width:40%;}
|
45
|
-
#main table.delays td.delay{ width:
|
45
|
+
#main table.delays td.args{ width:40%;word-break:break-word;}
|
46
|
+
#main table.delays td.delay{ width:20%;}
|
47
|
+
#main table.delays td.enqueuedat{ width:20%;}
|
46
48
|
|
47
49
|
|
48
50
|
#main table.workers td.icon {width:1%; background:#efefef;text-align:center;}
|
@@ -9,12 +9,14 @@
|
|
9
9
|
<p class='sub'>Showing <%= start = params[:start].to_i %> to <%= start + 20 %> of <b><%=size = resque.size(queue.to_sym)%></b> jobs</p><table class='jobs'>
|
10
10
|
<tr>
|
11
11
|
<th>Class</th>
|
12
|
-
<th>
|
12
|
+
<th>Args</th>
|
13
|
+
<th>Enqueued At</th>
|
13
14
|
</tr>
|
14
15
|
<% for job in (jobs = resque.peek(queue.to_sym, start, 20)) %>
|
15
16
|
<tr>
|
16
17
|
<td class='class'><%= job['class'] %></td>
|
17
18
|
<td class='args'><%=h job['args'].inspect %></td>
|
19
|
+
<td class='enqueuedat'><%=h enqueued_at(job['resque_enqueue_timestamp']) %></td>
|
18
20
|
</tr>
|
19
21
|
<% end %>
|
20
22
|
<% else %>
|
@@ -22,14 +24,16 @@
|
|
22
24
|
<tr>
|
23
25
|
<th>Class</th>
|
24
26
|
<th>Args</th>
|
27
|
+
<th>Enqueued At</th>
|
25
28
|
<th>Processes In</th>
|
26
29
|
</tr>
|
27
30
|
<% for job in (jobs = resque.peek(queue.to_sym, start, 20, :all_sorted)) %>
|
28
31
|
<tr>
|
29
32
|
<td class='class'><%= job['class'] %></td>
|
30
33
|
<td class='args'><%=h job['args'].inspect %></td>
|
34
|
+
<td class='enqueuedat'><%=h enqueued_at(job['resque_enqueue_timestamp']) %></td>
|
31
35
|
<td class='delay'><%=h processes_in(job['delay_until']) %></td>
|
32
|
-
|
36
|
+
</tr>
|
33
37
|
<% end %>
|
34
38
|
<% end %>
|
35
39
|
<% if jobs.empty? %>
|
data/lib/resque/version.rb
CHANGED
data/test/resque_test.rb
CHANGED
@@ -141,27 +141,27 @@ context "Resque" do
|
|
141
141
|
|
142
142
|
|
143
143
|
test "can pull items off a queue" do
|
144
|
-
assert_equal(
|
145
|
-
assert_equal(
|
146
|
-
assert_equal(
|
144
|
+
assert_equal('chris', pop_no_id(:people)['name'])
|
145
|
+
assert_equal('bob', pop_no_id(:people)['name'])
|
146
|
+
assert_equal('mark', pop_no_id(:people)['name'])
|
147
147
|
assert_equal nil, Resque.pop(:people)
|
148
148
|
end
|
149
149
|
|
150
150
|
test "knows how big a queue is" do
|
151
151
|
assert_equal 3, Resque.size(:people)
|
152
152
|
|
153
|
-
assert_equal(
|
153
|
+
assert_equal('chris', pop_no_id(:people)['name'])
|
154
154
|
assert_equal 2, Resque.size(:people)
|
155
155
|
|
156
|
-
assert_equal(
|
157
|
-
assert_equal(
|
156
|
+
assert_equal('bob', pop_no_id(:people)['name'])
|
157
|
+
assert_equal('mark', pop_no_id(:people)['name'])
|
158
158
|
assert_equal 0, Resque.size(:people)
|
159
159
|
end
|
160
160
|
|
161
161
|
test "can peek at a queue" do
|
162
162
|
peek = Resque.peek(:people)
|
163
163
|
peek.delete "_id"
|
164
|
-
assert_equal(
|
164
|
+
assert_equal('chris', peek['name'])
|
165
165
|
assert_equal 3, Resque.size(:people)
|
166
166
|
end
|
167
167
|
|
data/test/worker_test.rb
CHANGED
@@ -19,8 +19,9 @@ context "Resque::Worker" do
|
|
19
19
|
test "failed jobs report exception and message" do
|
20
20
|
Resque::Job.create(:jobs, BadJobWithSyntaxError)
|
21
21
|
@worker.work(0)
|
22
|
-
|
23
|
-
assert_equal('
|
22
|
+
failure = Resque::Failure.all.is_a?(Array) ? Resque::Failure.all.first : Resque::Failure.all
|
23
|
+
assert_equal('SyntaxError', failure['exception'])
|
24
|
+
assert_equal('Extra Bad job!', failure['error'])
|
24
25
|
end
|
25
26
|
|
26
27
|
test "fails uncompleted jobs on exit" do
|
@@ -142,6 +143,7 @@ context "Resque::Worker" do
|
|
142
143
|
@worker.work(0) do
|
143
144
|
task = @worker.job
|
144
145
|
task['payload'].delete "_id"
|
146
|
+
task['payload'].delete "resque_enqueue_timestamp"
|
145
147
|
assert_equal({"args"=>[20, "/tmp"], "class"=>"SomeJob"}, task['payload'])
|
146
148
|
assert task['run_at']
|
147
149
|
assert_equal 'jobs', task['queue'].to_s
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resque-igo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 1.1.
|
9
|
+
- 4
|
10
|
+
version: 1.1.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Nathan D Acuff
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-11-03 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|