resque 1.8.5 → 1.8.6
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of resque might be problematic. Click here for more details.
- data/lib/resque.rb +15 -5
- data/lib/resque/failure/hoptoad.rb +2 -2
- data/lib/resque/failure/redis.rb +3 -3
- data/lib/resque/job.rb +2 -1
- data/lib/resque/server.rb +3 -3
- data/lib/resque/server/test_helper.rb +1 -1
- data/lib/resque/server/views/layout.erb +1 -1
- data/lib/resque/server/views/stats.erb +1 -1
- data/lib/resque/version.rb +1 -1
- data/test/job_plugins_test.rb +21 -0
- data/test/redis-test.conf +0 -17
- data/test/resque_test.rb +1 -1
- data/test/test_helper.rb +1 -1
- metadata +22 -35
data/lib/resque.rb
CHANGED
@@ -49,6 +49,15 @@ module Resque
|
|
49
49
|
self.redis
|
50
50
|
end
|
51
51
|
|
52
|
+
def redis_id
|
53
|
+
# support 1.x versions of redis-rb
|
54
|
+
if redis.respond_to?(:server)
|
55
|
+
redis.server
|
56
|
+
else
|
57
|
+
redis.client.id
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
52
61
|
# The `before_first_fork` hook will be run in the **parent** process
|
53
62
|
# only once, before forking to run the first job. Be careful- any
|
54
63
|
# changes you make will be permanent for the lifespan of the
|
@@ -82,8 +91,8 @@ module Resque
|
|
82
91
|
end
|
83
92
|
|
84
93
|
# The `after_fork` hook will be run in the child process and is passed
|
85
|
-
# the current job. Any changes you make,
|
86
|
-
# long as the job currently being
|
94
|
+
# the current job. Any changes you make, therefore, will only live as
|
95
|
+
# long as the job currently being processed.
|
87
96
|
#
|
88
97
|
# Call with a block to set the hook.
|
89
98
|
# Call with no arguments to return the hook.
|
@@ -97,7 +106,7 @@ module Resque
|
|
97
106
|
end
|
98
107
|
|
99
108
|
def to_s
|
100
|
-
"Resque Client connected to #{
|
109
|
+
"Resque Client connected to #{redis_id}"
|
101
110
|
end
|
102
111
|
|
103
112
|
|
@@ -119,7 +128,7 @@ module Resque
|
|
119
128
|
decode redis.lpop("queue:#{queue}")
|
120
129
|
end
|
121
130
|
|
122
|
-
# Returns an
|
131
|
+
# Returns an integer representing the size of a queue.
|
123
132
|
# Queue name should be a string.
|
124
133
|
def size(queue)
|
125
134
|
redis.llen("queue:#{queue}").to_i
|
@@ -270,7 +279,8 @@ module Resque
|
|
270
279
|
:workers => workers.size.to_i,
|
271
280
|
:working => working.size,
|
272
281
|
:failed => Stat[:failed],
|
273
|
-
:servers => [
|
282
|
+
:servers => [redis_id],
|
283
|
+
:environment => defined?(RAILS_ENV) ? RAILS_ENV : (ENV['RACK_ENV'] || 'development')
|
274
284
|
}
|
275
285
|
end
|
276
286
|
|
@@ -83,7 +83,7 @@ module Resque
|
|
83
83
|
x.url "http://github.com/defunkt/resque"
|
84
84
|
end
|
85
85
|
x.error do
|
86
|
-
x.class exception.class.name
|
86
|
+
x.tag! "class", exception.class.name
|
87
87
|
x.message "#{exception.class.name}: #{exception.message}"
|
88
88
|
x.backtrace do
|
89
89
|
fill_in_backtrace_lines(x)
|
@@ -109,7 +109,7 @@ module Resque
|
|
109
109
|
end
|
110
110
|
|
111
111
|
def fill_in_backtrace_lines(x)
|
112
|
-
exception.backtrace.each do |unparsed_line|
|
112
|
+
Array(exception.backtrace).each do |unparsed_line|
|
113
113
|
_, file, number, method = unparsed_line.match(INPUT_FORMAT).to_a
|
114
114
|
x.line :file => file,:number => number
|
115
115
|
end
|
data/lib/resque/failure/redis.rb
CHANGED
@@ -9,7 +9,7 @@ module Resque
|
|
9
9
|
:payload => payload,
|
10
10
|
:exception => exception.class.to_s,
|
11
11
|
:error => exception.to_s,
|
12
|
-
:backtrace => exception.backtrace,
|
12
|
+
:backtrace => Array(exception.backtrace),
|
13
13
|
:worker => worker.to_s,
|
14
14
|
:queue => queue
|
15
15
|
}
|
@@ -24,11 +24,11 @@ module Resque
|
|
24
24
|
def self.all(start = 0, count = 1)
|
25
25
|
Resque.list_range(:failed, start, count)
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
def self.clear
|
29
29
|
Resque.redis.del(:failed)
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
def self.requeue(index)
|
33
33
|
item = all(index)
|
34
34
|
item['retried_at'] = Time.now.strftime("%Y/%m/%d %H:%M:%S")
|
data/lib/resque/job.rb
CHANGED
data/lib/resque/server.rb
CHANGED
@@ -106,7 +106,7 @@ module Resque
|
|
106
106
|
begin
|
107
107
|
erb page.to_sym, {:layout => layout}, :resque => Resque
|
108
108
|
rescue Errno::ECONNREFUSED
|
109
|
-
erb :error, {:layout => false}, :error => "Can't connect to Redis! (#{Resque.
|
109
|
+
erb :error, {:layout => false}, :error => "Can't connect to Redis! (#{Resque.redis_id})"
|
110
110
|
end
|
111
111
|
end
|
112
112
|
|
@@ -124,7 +124,7 @@ module Resque
|
|
124
124
|
show page
|
125
125
|
end
|
126
126
|
end
|
127
|
-
|
127
|
+
|
128
128
|
post "/queues/:id/remove" do
|
129
129
|
Resque.remove_queue(params[:id])
|
130
130
|
redirect u('queues')
|
@@ -150,7 +150,7 @@ module Resque
|
|
150
150
|
Resque::Failure.clear
|
151
151
|
redirect u('failed')
|
152
152
|
end
|
153
|
-
|
153
|
+
|
154
154
|
get "/failed/requeue/:index" do
|
155
155
|
Resque::Failure.requeue(params[:index])
|
156
156
|
if request.xhr?
|
@@ -37,7 +37,7 @@
|
|
37
37
|
|
38
38
|
<div id="footer">
|
39
39
|
<p>Powered by <a href="http://github.com/defunkt/resque">Resque</a> v<%=Resque::Version%></p>
|
40
|
-
<p>Connected to Redis namespace <%= Resque.redis.namespace %> on <%=Resque.
|
40
|
+
<p>Connected to Redis namespace <%= Resque.redis.namespace %> on <%=Resque.redis_id%></p>
|
41
41
|
</div>
|
42
42
|
|
43
43
|
</body>
|
data/lib/resque/version.rb
CHANGED
data/test/job_plugins_test.rb
CHANGED
@@ -177,6 +177,27 @@ context "Resque::Plugin ordering around_perform" do
|
|
177
177
|
assert_equal false, result, "perform returned false"
|
178
178
|
assert_equal [:around_perform, :around_perform0], history
|
179
179
|
end
|
180
|
+
|
181
|
+
module AroundPerformGetsJobResult
|
182
|
+
@@result = nil
|
183
|
+
def last_job_result
|
184
|
+
@@result
|
185
|
+
end
|
186
|
+
|
187
|
+
def around_perform_gets_job_result(*args)
|
188
|
+
@@result = yield
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
class AroundPerformJobWithReturnValue < GoodJob
|
193
|
+
extend AroundPerformGetsJobResult
|
194
|
+
end
|
195
|
+
|
196
|
+
test "the job is aborted if an around_perform hook does not yield" do
|
197
|
+
result = perform_job(AroundPerformJobWithReturnValue, 'Bob')
|
198
|
+
assert_equal true, result, "perform returned true"
|
199
|
+
assert_equal 'Good job, Bob', AroundPerformJobWithReturnValue.last_job_result
|
200
|
+
end
|
180
201
|
end
|
181
202
|
|
182
203
|
context "Resque::Plugin ordering on_failure" do
|
data/test/redis-test.conf
CHANGED
@@ -113,20 +113,3 @@ databases 16
|
|
113
113
|
# single TCP packet. Uses a bit more CPU but most of the times it is a win
|
114
114
|
# in terms of number of queries per second. Use 'yes' if unsure.
|
115
115
|
glueoutputbuf yes
|
116
|
-
|
117
|
-
# Use object sharing. Can save a lot of memory if you have many common
|
118
|
-
# string in your dataset, but performs lookups against the shared objects
|
119
|
-
# pool so it uses more CPU and can be a bit slower. Usually it's a good
|
120
|
-
# idea.
|
121
|
-
#
|
122
|
-
# When object sharing is enabled (shareobjects yes) you can use
|
123
|
-
# shareobjectspoolsize to control the size of the pool used in order to try
|
124
|
-
# object sharing. A bigger pool size will lead to better sharing capabilities.
|
125
|
-
# In general you want this value to be at least the double of the number of
|
126
|
-
# very common strings you have in your dataset.
|
127
|
-
#
|
128
|
-
# WARNING: object sharing is experimental, don't enable this feature
|
129
|
-
# in production before of Redis 1.0-stable. Still please try this feature in
|
130
|
-
# your development environment so that we can test it better.
|
131
|
-
shareobjects no
|
132
|
-
shareobjectspoolsize 1024
|
data/test/resque_test.rb
CHANGED
@@ -216,7 +216,7 @@ context "Resque" do
|
|
216
216
|
assert_equal 3, stats[:queues]
|
217
217
|
assert_equal 3, stats[:processed]
|
218
218
|
assert_equal 1, stats[:failed]
|
219
|
-
assert_equal ['localhost:9736'], stats[:servers]
|
219
|
+
assert_equal [Resque.redis.respond_to?(:server) ? 'localhost:9736' : 'redis://localhost:9736/0'], stats[:servers]
|
220
220
|
end
|
221
221
|
|
222
222
|
test "decode bad json" do
|
data/test/test_helper.rb
CHANGED
@@ -31,7 +31,7 @@ at_exit do
|
|
31
31
|
exit_code = Test::Unit::AutoRunner.run
|
32
32
|
end
|
33
33
|
|
34
|
-
pid = `ps -
|
34
|
+
pid = `ps -A -o pid,command | grep [r]edis-test`.split(" ")[0]
|
35
35
|
puts "Killing test redis server..."
|
36
36
|
`rm -f #{dir}/dump.rdb`
|
37
37
|
Process.kill("KILL", pid.to_i)
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resque
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 61
|
5
4
|
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 1
|
8
7
|
- 8
|
9
|
-
-
|
10
|
-
version: 1.8.
|
8
|
+
- 6
|
9
|
+
version: 1.8.6
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Chris Wanstrath
|
@@ -15,71 +14,63 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date: 2010-
|
17
|
+
date: 2010-06-03 00:00:00 -07:00
|
19
18
|
default_executable:
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
|
-
name: redis
|
21
|
+
name: redis-namespace
|
23
22
|
prerelease: false
|
24
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
24
|
requirements:
|
27
25
|
- - ~>
|
28
26
|
- !ruby/object:Gem::Version
|
29
|
-
hash: 23
|
30
27
|
segments:
|
31
|
-
- 1
|
32
28
|
- 0
|
29
|
+
- 5
|
33
30
|
- 0
|
34
|
-
version:
|
31
|
+
version: 0.5.0
|
35
32
|
type: :runtime
|
36
33
|
version_requirements: *id001
|
37
34
|
- !ruby/object:Gem::Dependency
|
38
|
-
name:
|
35
|
+
name: vegas
|
39
36
|
prerelease: false
|
40
37
|
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
38
|
requirements:
|
43
39
|
- - ~>
|
44
40
|
- !ruby/object:Gem::Version
|
45
|
-
hash: 15
|
46
41
|
segments:
|
47
42
|
- 0
|
48
|
-
-
|
49
|
-
-
|
50
|
-
version: 0.
|
43
|
+
- 1
|
44
|
+
- 2
|
45
|
+
version: 0.1.2
|
51
46
|
type: :runtime
|
52
47
|
version_requirements: *id002
|
53
48
|
- !ruby/object:Gem::Dependency
|
54
|
-
name:
|
49
|
+
name: sinatra
|
55
50
|
prerelease: false
|
56
51
|
requirement: &id003 !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
52
|
requirements:
|
59
|
-
- -
|
53
|
+
- - ">="
|
60
54
|
- !ruby/object:Gem::Version
|
61
|
-
hash: 31
|
62
55
|
segments:
|
63
56
|
- 0
|
64
|
-
-
|
57
|
+
- 9
|
65
58
|
- 2
|
66
|
-
version: 0.
|
59
|
+
version: 0.9.2
|
67
60
|
type: :runtime
|
68
61
|
version_requirements: *id003
|
69
62
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
63
|
+
name: json
|
71
64
|
prerelease: false
|
72
65
|
requirement: &id004 !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
66
|
requirements:
|
75
|
-
- -
|
67
|
+
- - ~>
|
76
68
|
- !ruby/object:Gem::Version
|
77
|
-
hash: 63
|
78
69
|
segments:
|
79
|
-
-
|
80
|
-
-
|
81
|
-
-
|
82
|
-
version:
|
70
|
+
- 1
|
71
|
+
- 1
|
72
|
+
- 3
|
73
|
+
version: 1.1.3
|
83
74
|
type: :runtime
|
84
75
|
version_requirements: *id004
|
85
76
|
description: " Resque is a Redis-backed Ruby library for creating background jobs,\n placing those jobs on multiple queues, and processing them later.\n\n Background jobs can be any Ruby class or module that responds to\n perform. Your existing classes can easily be converted to background\n jobs or you can create new classes specifically to do work. Or, you\n can do both.\n\n Resque is heavily inspired by DelayedJob (which rocks) and is\n comprised of three parts:\n\n * A Ruby library for creating, querying, and processing jobs\n * A Rake task for starting a worker which processes jobs\n * A Sinatra app for monitoring queues, jobs, and workers.\n"
|
@@ -144,7 +135,7 @@ files:
|
|
144
135
|
- tasks/redis.rake
|
145
136
|
- tasks/resque.rake
|
146
137
|
has_rdoc: true
|
147
|
-
homepage: http://github.com/defunkt/
|
138
|
+
homepage: http://github.com/defunkt/resque
|
148
139
|
licenses: []
|
149
140
|
|
150
141
|
post_install_message:
|
@@ -153,27 +144,23 @@ rdoc_options:
|
|
153
144
|
require_paths:
|
154
145
|
- lib
|
155
146
|
required_ruby_version: !ruby/object:Gem::Requirement
|
156
|
-
none: false
|
157
147
|
requirements:
|
158
148
|
- - ">="
|
159
149
|
- !ruby/object:Gem::Version
|
160
|
-
hash: 3
|
161
150
|
segments:
|
162
151
|
- 0
|
163
152
|
version: "0"
|
164
153
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
165
|
-
none: false
|
166
154
|
requirements:
|
167
155
|
- - ">="
|
168
156
|
- !ruby/object:Gem::Version
|
169
|
-
hash: 3
|
170
157
|
segments:
|
171
158
|
- 0
|
172
159
|
version: "0"
|
173
160
|
requirements: []
|
174
161
|
|
175
162
|
rubyforge_project:
|
176
|
-
rubygems_version: 1.3.
|
163
|
+
rubygems_version: 1.3.6
|
177
164
|
signing_key:
|
178
165
|
specification_version: 3
|
179
166
|
summary: Resque is a Redis-backed queueing system.
|