resque 1.7.0 → 1.7.1
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/HISTORY.md +6 -1
- data/README.markdown +2 -2
- data/Rakefile +56 -15
- data/{HOOKS.md → docs/HOOKS.md} +3 -2
- data/docs/PLUGINS.md +93 -0
- data/lib/resque.rb +1 -0
- data/lib/resque/job.rb +5 -5
- data/lib/resque/plugin.rb +46 -0
- data/lib/resque/version.rb +1 -1
- data/lib/resque/worker.rb +4 -0
- data/test/job_plugins_test.rb +209 -0
- data/test/plugin_test.rb +116 -0
- data/test/worker_test.rb +1 -1
- metadata +11 -5
data/HISTORY.md
CHANGED
@@ -1,6 +1,11 @@
|
|
1
|
+
## 1.7.1 (2010-04-02)
|
2
|
+
|
3
|
+
* Bugfix: Make job hook execution order consistent
|
4
|
+
* Bugfix: stdout buffering in child process
|
5
|
+
|
1
6
|
## 1.7.0 (2010-03-31)
|
2
7
|
|
3
|
-
* Job hooks API. See HOOKS.md.
|
8
|
+
* Job hooks API. See docs/HOOKS.md.
|
4
9
|
* web: Hovering over dates shows a timestamp
|
5
10
|
* web: AJAXify retry action for failed jobs
|
6
11
|
* web bugfix: Fix pagination bug
|
data/README.markdown
CHANGED
@@ -662,7 +662,7 @@ For a list of available plugins see
|
|
662
662
|
|
663
663
|
If you'd like to write your own plugin, or want to customize Resque
|
664
664
|
using hooks (such as `Resque.after_fork`), see
|
665
|
-
[HOOKS.md](http://github.com/defunkt/resque/blob/master/HOOKS.md).
|
665
|
+
[docs/HOOKS.md](http://github.com/defunkt/resque/blob/master/HOOKS.md).
|
666
666
|
|
667
667
|
|
668
668
|
Namespaces
|
@@ -762,7 +762,7 @@ Mailing List
|
|
762
762
|
|
763
763
|
To join the list simply send an email to <resque@librelist.com>. This
|
764
764
|
will subscribe you and send you information about your subscription,
|
765
|
-
|
765
|
+
including unsubscribe information.
|
766
766
|
|
767
767
|
The archive can be found at <http://librelist.com/browser/>.
|
768
768
|
|
data/Rakefile
CHANGED
@@ -1,29 +1,44 @@
|
|
1
|
+
#
|
2
|
+
# Setup
|
3
|
+
#
|
4
|
+
|
1
5
|
load 'tasks/redis.rake'
|
6
|
+
require 'rake/testtask'
|
2
7
|
|
3
8
|
$LOAD_PATH.unshift 'lib'
|
4
9
|
require 'resque/tasks'
|
5
10
|
|
11
|
+
def command?(command)
|
12
|
+
system("type #{command} > /dev/null")
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
#
|
17
|
+
# Tests
|
18
|
+
#
|
19
|
+
|
6
20
|
task :default => :test
|
7
21
|
|
8
|
-
desc "Run
|
22
|
+
desc "Run the test suite"
|
9
23
|
task :test do
|
10
|
-
|
11
|
-
|
12
|
-
|
24
|
+
rg = command?(:rg)
|
25
|
+
Dir['test/**/*_test.rb'].each do |f|
|
26
|
+
rg ? sh("rg #{f}") : ruby(f)
|
13
27
|
end
|
28
|
+
end
|
14
29
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
30
|
+
if command? :kicker
|
31
|
+
desc "Launch Kicker (like autotest)"
|
32
|
+
task :kicker do
|
33
|
+
puts "Kicking... (ctrl+c to cancel)"
|
34
|
+
exec "kicker -e rake test lib examples"
|
20
35
|
end
|
21
36
|
end
|
22
37
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
38
|
+
|
39
|
+
#
|
40
|
+
# Gem
|
41
|
+
#
|
27
42
|
|
28
43
|
task :install => [ 'redis:install', 'dtach:install' ]
|
29
44
|
|
@@ -36,8 +51,7 @@ begin
|
|
36
51
|
|
37
52
|
Jeweler::Tasks.new do |gemspec|
|
38
53
|
gemspec.name = "resque"
|
39
|
-
gemspec.summary = ""
|
40
|
-
gemspec.description = ""
|
54
|
+
gemspec.summary = "Resque is a Redis-backed queueing system."
|
41
55
|
gemspec.email = "chris@ozmm.org"
|
42
56
|
gemspec.homepage = "http://github.com/defunkt/resque"
|
43
57
|
gemspec.authors = ["Chris Wanstrath"]
|
@@ -48,18 +62,45 @@ begin
|
|
48
62
|
gemspec.add_dependency "vegas", ">=0.1.2"
|
49
63
|
gemspec.add_dependency "sinatra", ">=0.9.2"
|
50
64
|
gemspec.add_development_dependency "jeweler"
|
65
|
+
|
66
|
+
gemspec.description = <<description
|
67
|
+
Resque is a Redis-backed Ruby library for creating background jobs,
|
68
|
+
placing those jobs on multiple queues, and processing them later.
|
69
|
+
|
70
|
+
Background jobs can be any Ruby class or module that responds to
|
71
|
+
perform. Your existing classes can easily be converted to background
|
72
|
+
jobs or you can create new classes specifically to do work. Or, you
|
73
|
+
can do both.
|
74
|
+
|
75
|
+
Resque is heavily inspired by DelayedJob (which rocks) and is
|
76
|
+
comprised of three parts:
|
77
|
+
|
78
|
+
* A Ruby library for creating, querying, and processing jobs
|
79
|
+
* A Rake task for starting a worker which processes jobs
|
80
|
+
* A Sinatra app for monitoring queues, jobs, and workers.
|
81
|
+
description
|
51
82
|
end
|
52
83
|
rescue LoadError
|
53
84
|
puts "Jeweler not available. Install it with: "
|
54
85
|
puts "gem install jeweler"
|
55
86
|
end
|
56
87
|
|
88
|
+
|
89
|
+
#
|
90
|
+
# Documentation
|
91
|
+
#
|
92
|
+
|
57
93
|
begin
|
58
94
|
require 'sdoc_helpers'
|
59
95
|
rescue LoadError
|
60
96
|
puts "sdoc support not enabled. Please gem install sdoc-helpers."
|
61
97
|
end
|
62
98
|
|
99
|
+
|
100
|
+
#
|
101
|
+
# Publishing
|
102
|
+
#
|
103
|
+
|
63
104
|
desc "Push a new version to Gemcutter"
|
64
105
|
task :publish => [ :test, :gemspec, :build ] do
|
65
106
|
system "git tag v#{Resque::Version}"
|
data/{HOOKS.md → docs/HOOKS.md}
RENAMED
@@ -60,7 +60,9 @@ like this:
|
|
60
60
|
|
61
61
|
Once this hook is made available to your job (either by way of
|
62
62
|
inheritence or `extend`), it will be run before the job's `perform`
|
63
|
-
method is called.
|
63
|
+
method is called. Hooks of each type are executed in alphabetical order,
|
64
|
+
so `before_perform_a` will always be executed before `before_perform_b`.
|
65
|
+
An unnamed hook (`before_perform`) will be executed first.
|
64
66
|
|
65
67
|
The available hooks are:
|
66
68
|
|
@@ -117,4 +119,3 @@ Modules are even better because jobs can use many of them.
|
|
117
119
|
...
|
118
120
|
end
|
119
121
|
end
|
120
|
-
|
data/docs/PLUGINS.md
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
Resque Plugins
|
2
|
+
==============
|
3
|
+
|
4
|
+
Resque encourages plugin development. For a list of available plugins,
|
5
|
+
please see <http://wiki.github.com/defunkt/resque/plugins>.
|
6
|
+
|
7
|
+
The `docs/HOOKS.md` file included with Resque documents the available
|
8
|
+
hooks you can use to add or change Resque functionality. This document
|
9
|
+
describes best practice for plugins themselves.
|
10
|
+
|
11
|
+
|
12
|
+
Version
|
13
|
+
-------
|
14
|
+
|
15
|
+
Plugins should declare the major.minor version of Resque they are
|
16
|
+
known to work with explicitly in their README.
|
17
|
+
|
18
|
+
For example, if your plugin depends on features in Resque 2.1, please
|
19
|
+
list "Depends on Resque 2.1" very prominently near the beginning of
|
20
|
+
your README.
|
21
|
+
|
22
|
+
Because Resque uses [Semantic Versioning][sv], you can safely make the
|
23
|
+
following assumptions:
|
24
|
+
|
25
|
+
* Your plugin will work with 2.2, 2.3, etc - no methods will be
|
26
|
+
removed or changed, only added.
|
27
|
+
* Your plugin might not work with 3.0+, as APIs may change or be
|
28
|
+
removed.
|
29
|
+
|
30
|
+
|
31
|
+
Namespace
|
32
|
+
---------
|
33
|
+
|
34
|
+
All plugins should live under the `Resque::Plugins` module to avoid
|
35
|
+
clashing with first class Resque constants or other Ruby libraries.
|
36
|
+
|
37
|
+
Good:
|
38
|
+
|
39
|
+
* Resque::Plugins::Lock
|
40
|
+
* Resque::Plugins::FastRetry
|
41
|
+
|
42
|
+
Bad:
|
43
|
+
|
44
|
+
* Resque::Lock
|
45
|
+
* ResqueQueue
|
46
|
+
|
47
|
+
|
48
|
+
Gem Name
|
49
|
+
--------
|
50
|
+
|
51
|
+
Gem names should be in the format of `resque-FEATURE`, where `FEATURE`
|
52
|
+
succinctly describes the feature your plugin adds to Resque.
|
53
|
+
|
54
|
+
Good:
|
55
|
+
|
56
|
+
* resque-status
|
57
|
+
* resque-scheduler
|
58
|
+
|
59
|
+
Bad:
|
60
|
+
|
61
|
+
* multi-queue
|
62
|
+
* defunkt-resque-lock
|
63
|
+
|
64
|
+
|
65
|
+
Hooks
|
66
|
+
-----
|
67
|
+
|
68
|
+
Job hook names should be namespaced to work properly.
|
69
|
+
|
70
|
+
Good:
|
71
|
+
|
72
|
+
* before_perform_lock
|
73
|
+
* around_perform_check_status
|
74
|
+
|
75
|
+
Bad:
|
76
|
+
|
77
|
+
* before_perform
|
78
|
+
* on_failure
|
79
|
+
|
80
|
+
|
81
|
+
Lint
|
82
|
+
----
|
83
|
+
|
84
|
+
Plugins should test compliance to this document using the
|
85
|
+
`Resque::Plugin.lint` method.
|
86
|
+
|
87
|
+
For example:
|
88
|
+
|
89
|
+
def test_lint
|
90
|
+
assert Resque::Plugin.lint(Resque::Plugins::Lock)
|
91
|
+
end
|
92
|
+
|
93
|
+
[sv]: http://semver.org/
|
data/lib/resque.rb
CHANGED
data/lib/resque/job.rb
CHANGED
@@ -109,10 +109,10 @@ module Resque
|
|
109
109
|
job_args = args || []
|
110
110
|
job_was_performed = false
|
111
111
|
|
112
|
-
before_hooks =
|
113
|
-
around_hooks =
|
114
|
-
after_hooks =
|
115
|
-
failure_hooks =
|
112
|
+
before_hooks = Plugin.before_hooks(job)
|
113
|
+
around_hooks = Plugin.around_hooks(job)
|
114
|
+
after_hooks = Plugin.after_hooks(job)
|
115
|
+
failure_hooks = Plugin.failure_hooks(job)
|
116
116
|
|
117
117
|
begin
|
118
118
|
# Execute before_perform hook. Abort the job gracefully if
|
@@ -132,7 +132,7 @@ module Resque
|
|
132
132
|
else
|
133
133
|
# We want to nest all around_perform plugins, with the last one
|
134
134
|
# finally calling perform
|
135
|
-
stack = around_hooks.inject(nil) do |last_hook, hook|
|
135
|
+
stack = around_hooks.reverse.inject(nil) do |last_hook, hook|
|
136
136
|
if last_hook
|
137
137
|
lambda do
|
138
138
|
job.send(hook, *job_args) { last_hook.call }
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Resque
|
2
|
+
module Plugin
|
3
|
+
extend self
|
4
|
+
|
5
|
+
LintError = Class.new(RuntimeError)
|
6
|
+
|
7
|
+
# Ensure that your plugin conforms to good hook naming conventions.
|
8
|
+
#
|
9
|
+
# Resque::Plugin.lint(MyResquePlugin)
|
10
|
+
def lint(plugin)
|
11
|
+
hooks = before_hooks(plugin) + around_hooks(plugin) + after_hooks(plugin)
|
12
|
+
|
13
|
+
hooks.each do |hook|
|
14
|
+
if hook =~ /perform$/
|
15
|
+
raise LintError, "#{plugin}.#{hook} is not namespaced"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
failure_hooks(plugin).each do |hook|
|
20
|
+
if hook =~ /failure$/
|
21
|
+
raise LintError, "#{plugin}.#{hook} is not namespaced"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# Given an object, returns a list `before_perform` hook names.
|
27
|
+
def before_hooks(job)
|
28
|
+
job.methods.grep(/^before_perform/).sort
|
29
|
+
end
|
30
|
+
|
31
|
+
# Given an object, returns a list `around_perform` hook names.
|
32
|
+
def around_hooks(job)
|
33
|
+
job.methods.grep(/^around_perform/).sort
|
34
|
+
end
|
35
|
+
|
36
|
+
# Given an object, returns a list `after_perform` hook names.
|
37
|
+
def after_hooks(job)
|
38
|
+
job.methods.grep(/^after_perform/).sort
|
39
|
+
end
|
40
|
+
|
41
|
+
# Given an object, returns a list `on_failure` hook names.
|
42
|
+
def failure_hooks(job)
|
43
|
+
job.methods.grep(/^on_failure/).sort
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/lib/resque/version.rb
CHANGED
data/lib/resque/worker.rb
CHANGED
@@ -207,6 +207,10 @@ module Resque
|
|
207
207
|
prune_dead_workers
|
208
208
|
run_hook :before_first_fork
|
209
209
|
register_worker
|
210
|
+
|
211
|
+
# Fix buffering so we can `rake resque:work > resque.log` and
|
212
|
+
# get output from the child in there.
|
213
|
+
$stdout.sync = true
|
210
214
|
end
|
211
215
|
|
212
216
|
# Enables GC Optimizations if you're running REE.
|
@@ -0,0 +1,209 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
|
3
|
+
context "Multiple plugins with multiple hooks" do
|
4
|
+
include PerformJob
|
5
|
+
|
6
|
+
module Plugin1
|
7
|
+
def before_perform_record_history1(history)
|
8
|
+
history << :before1
|
9
|
+
end
|
10
|
+
def after_perform_record_history1(history)
|
11
|
+
history << :after1
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
module Plugin2
|
16
|
+
def before_perform_record_history2(history)
|
17
|
+
history << :before2
|
18
|
+
end
|
19
|
+
def after_perform_record_history2(history)
|
20
|
+
history << :after2
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class ManyBeforesJob
|
25
|
+
extend Plugin1
|
26
|
+
extend Plugin2
|
27
|
+
def self.perform(history)
|
28
|
+
history << :perform
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
test "hooks of each type are executed in alphabetical order" do
|
33
|
+
result = perform_job(ManyBeforesJob, history=[])
|
34
|
+
assert_equal true, result, "perform returned true"
|
35
|
+
assert_equal [:before1, :before2, :perform, :after1, :after2], history
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context "Resque::Plugin ordering before_perform" do
|
40
|
+
include PerformJob
|
41
|
+
|
42
|
+
module BeforePerformPlugin
|
43
|
+
def before_perform1(history)
|
44
|
+
history << :before_perform1
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
class BeforePerformJob
|
49
|
+
extend BeforePerformPlugin
|
50
|
+
def self.perform(history)
|
51
|
+
history << :perform
|
52
|
+
end
|
53
|
+
def self.before_perform(history)
|
54
|
+
history << :before_perform
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
test "before_perform hooks are executed in order" do
|
59
|
+
result = perform_job(BeforePerformJob, history=[])
|
60
|
+
assert_equal true, result, "perform returned true"
|
61
|
+
assert_equal [:before_perform, :before_perform1, :perform], history
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
context "Resque::Plugin ordering after_perform" do
|
66
|
+
include PerformJob
|
67
|
+
|
68
|
+
module AfterPerformPlugin
|
69
|
+
def after_perform_record_history(history)
|
70
|
+
history << :after_perform1
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
class AfterPerformJob
|
75
|
+
extend AfterPerformPlugin
|
76
|
+
def self.perform(history)
|
77
|
+
history << :perform
|
78
|
+
end
|
79
|
+
def self.after_perform(history)
|
80
|
+
history << :after_perform
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
test "after_perform hooks are executed in order" do
|
85
|
+
result = perform_job(AfterPerformJob, history=[])
|
86
|
+
assert_equal true, result, "perform returned true"
|
87
|
+
assert_equal [:perform, :after_perform, :after_perform1], history
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
context "Resque::Plugin ordering around_perform" do
|
92
|
+
include PerformJob
|
93
|
+
|
94
|
+
module AroundPerformPlugin1
|
95
|
+
def around_perform1(history)
|
96
|
+
history << :around_perform_plugin1
|
97
|
+
yield
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
class AroundPerformJustPerformsJob
|
102
|
+
extend AroundPerformPlugin1
|
103
|
+
def self.perform(history)
|
104
|
+
history << :perform
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
test "around_perform hooks are executed before the job" do
|
109
|
+
result = perform_job(AroundPerformJustPerformsJob, history=[])
|
110
|
+
assert_equal true, result, "perform returned true"
|
111
|
+
assert_equal [:around_perform_plugin1, :perform], history
|
112
|
+
end
|
113
|
+
|
114
|
+
class AroundPerformJob
|
115
|
+
extend AroundPerformPlugin1
|
116
|
+
def self.perform(history)
|
117
|
+
history << :perform
|
118
|
+
end
|
119
|
+
def self.around_perform(history)
|
120
|
+
history << :around_perform
|
121
|
+
yield
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
test "around_perform hooks are executed in order" do
|
126
|
+
result = perform_job(AroundPerformJob, history=[])
|
127
|
+
assert_equal true, result, "perform returned true"
|
128
|
+
assert_equal [:around_perform, :around_perform_plugin1, :perform], history
|
129
|
+
end
|
130
|
+
|
131
|
+
module AroundPerformPlugin2
|
132
|
+
def around_perform2(history)
|
133
|
+
history << :around_perform_plugin2
|
134
|
+
yield
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
class AroundPerformJob2
|
139
|
+
extend AroundPerformPlugin1
|
140
|
+
extend AroundPerformPlugin2
|
141
|
+
def self.perform(history)
|
142
|
+
history << :perform
|
143
|
+
end
|
144
|
+
def self.around_perform(history)
|
145
|
+
history << :around_perform
|
146
|
+
yield
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
test "many around_perform are executed in order" do
|
151
|
+
result = perform_job(AroundPerformJob2, history=[])
|
152
|
+
assert_equal true, result, "perform returned true"
|
153
|
+
assert_equal [:around_perform, :around_perform_plugin1, :around_perform_plugin2, :perform], history
|
154
|
+
end
|
155
|
+
|
156
|
+
module AroundPerformDoesNotYield
|
157
|
+
def around_perform0(history)
|
158
|
+
history << :around_perform0
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
class AroundPerformJob3
|
163
|
+
extend AroundPerformPlugin1
|
164
|
+
extend AroundPerformPlugin2
|
165
|
+
extend AroundPerformDoesNotYield
|
166
|
+
def self.perform(history)
|
167
|
+
history << :perform
|
168
|
+
end
|
169
|
+
def self.around_perform(history)
|
170
|
+
history << :around_perform
|
171
|
+
yield
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
test "the job is aborted if an around_perform hook does not yield" do
|
176
|
+
result = perform_job(AroundPerformJob3, history=[])
|
177
|
+
assert_equal false, result, "perform returned false"
|
178
|
+
assert_equal [:around_perform, :around_perform0], history
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
context "Resque::Plugin ordering on_failure" do
|
183
|
+
include PerformJob
|
184
|
+
|
185
|
+
module OnFailurePlugin
|
186
|
+
def on_failure1(exception, history)
|
187
|
+
history << "#{exception.message} plugin"
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
class FailureJob
|
192
|
+
extend OnFailurePlugin
|
193
|
+
def self.perform(history)
|
194
|
+
history << :perform
|
195
|
+
raise StandardError, "oh no"
|
196
|
+
end
|
197
|
+
def self.on_failure(exception, history)
|
198
|
+
history << exception.message
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
test "on_failure hooks are executed in order" do
|
203
|
+
history = []
|
204
|
+
assert_raises StandardError do
|
205
|
+
perform_job(FailureJob, history)
|
206
|
+
end
|
207
|
+
assert_equal [:perform, "oh no", "oh no plugin"], history
|
208
|
+
end
|
209
|
+
end
|
data/test/plugin_test.rb
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
|
3
|
+
context "Resque::Plugin finding hooks" do
|
4
|
+
module SimplePlugin
|
5
|
+
extend self
|
6
|
+
def before_perform1; end
|
7
|
+
def before_perform; end
|
8
|
+
def before_perform2; end
|
9
|
+
def after_perform1; end
|
10
|
+
def after_perform; end
|
11
|
+
def after_perform2; end
|
12
|
+
def perform; end
|
13
|
+
def around_perform1; end
|
14
|
+
def around_perform; end
|
15
|
+
def around_perform2; end
|
16
|
+
def on_failure1; end
|
17
|
+
def on_failure; end
|
18
|
+
def on_failure2; end
|
19
|
+
end
|
20
|
+
|
21
|
+
test "before_perform hooks are found and sorted" do
|
22
|
+
assert_equal ["before_perform", "before_perform1", "before_perform2"], Resque::Plugin.before_hooks(SimplePlugin)
|
23
|
+
end
|
24
|
+
|
25
|
+
test "after_perform hooks are found and sorted" do
|
26
|
+
assert_equal ["after_perform", "after_perform1", "after_perform2"], Resque::Plugin.after_hooks(SimplePlugin)
|
27
|
+
end
|
28
|
+
|
29
|
+
test "around_perform hooks are found and sorted" do
|
30
|
+
assert_equal ["around_perform", "around_perform1", "around_perform2"], Resque::Plugin.around_hooks(SimplePlugin)
|
31
|
+
end
|
32
|
+
|
33
|
+
test "on_failure hooks are found and sorted" do
|
34
|
+
assert_equal ["on_failure", "on_failure1", "on_failure2"], Resque::Plugin.failure_hooks(SimplePlugin)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context "Resque::Plugin linting" do
|
39
|
+
module BadBefore
|
40
|
+
def self.before_perform; end
|
41
|
+
end
|
42
|
+
module BadAfter
|
43
|
+
def self.after_perform; end
|
44
|
+
end
|
45
|
+
module BadAround
|
46
|
+
def self.around_perform; end
|
47
|
+
end
|
48
|
+
module BadFailure
|
49
|
+
def self.on_failure; end
|
50
|
+
end
|
51
|
+
|
52
|
+
test "before_perform must be namespaced" do
|
53
|
+
begin
|
54
|
+
Resque::Plugin.lint(BadBefore)
|
55
|
+
assert false, "should have failed"
|
56
|
+
rescue Resque::Plugin::LintError => e
|
57
|
+
assert_equal "BadBefore.before_perform is not namespaced", e.message
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
test "after_perform must be namespaced" do
|
62
|
+
begin
|
63
|
+
Resque::Plugin.lint(BadAfter)
|
64
|
+
assert false, "should have failed"
|
65
|
+
rescue Resque::Plugin::LintError => e
|
66
|
+
assert_equal "BadAfter.after_perform is not namespaced", e.message
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
test "around_perform must be namespaced" do
|
71
|
+
begin
|
72
|
+
Resque::Plugin.lint(BadAround)
|
73
|
+
assert false, "should have failed"
|
74
|
+
rescue Resque::Plugin::LintError => e
|
75
|
+
assert_equal "BadAround.around_perform is not namespaced", e.message
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
test "on_failure must be namespaced" do
|
80
|
+
begin
|
81
|
+
Resque::Plugin.lint(BadFailure)
|
82
|
+
assert false, "should have failed"
|
83
|
+
rescue Resque::Plugin::LintError => e
|
84
|
+
assert_equal "BadFailure.on_failure is not namespaced", e.message
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
module GoodBefore
|
89
|
+
def self.before_perform1; end
|
90
|
+
end
|
91
|
+
module GoodAfter
|
92
|
+
def self.after_perform1; end
|
93
|
+
end
|
94
|
+
module GoodAround
|
95
|
+
def self.around_perform1; end
|
96
|
+
end
|
97
|
+
module GoodFailure
|
98
|
+
def self.on_failure1; end
|
99
|
+
end
|
100
|
+
|
101
|
+
test "before_perform1 is an ok name" do
|
102
|
+
Resque::Plugin.lint(GoodBefore)
|
103
|
+
end
|
104
|
+
|
105
|
+
test "after_perform1 is an ok name" do
|
106
|
+
Resque::Plugin.lint(GoodAfter)
|
107
|
+
end
|
108
|
+
|
109
|
+
test "around_perform1 is an ok name" do
|
110
|
+
Resque::Plugin.lint(GoodAround)
|
111
|
+
end
|
112
|
+
|
113
|
+
test "on_failure1 is an ok name" do
|
114
|
+
Resque::Plugin.lint(GoodFailure)
|
115
|
+
end
|
116
|
+
end
|
data/test/worker_test.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resque
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Wanstrath
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-
|
12
|
+
date: 2010-04-02 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -62,7 +62,7 @@ dependencies:
|
|
62
62
|
- !ruby/object:Gem::Version
|
63
63
|
version: "0"
|
64
64
|
version:
|
65
|
-
description: ""
|
65
|
+
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"
|
66
66
|
email: chris@ozmm.org
|
67
67
|
executables:
|
68
68
|
- resque
|
@@ -77,7 +77,6 @@ files:
|
|
77
77
|
- .kick
|
78
78
|
- CONTRIBUTORS
|
79
79
|
- HISTORY.md
|
80
|
-
- HOOKS.md
|
81
80
|
- LICENSE
|
82
81
|
- README.markdown
|
83
82
|
- Rakefile
|
@@ -85,6 +84,8 @@ files:
|
|
85
84
|
- bin/resque-web
|
86
85
|
- config.ru
|
87
86
|
- deps.rip
|
87
|
+
- docs/HOOKS.md
|
88
|
+
- docs/PLUGINS.md
|
88
89
|
- examples/async_helper.rb
|
89
90
|
- examples/demo/README.markdown
|
90
91
|
- examples/demo/Rakefile
|
@@ -106,6 +107,7 @@ files:
|
|
106
107
|
- lib/resque/failure/redis.rb
|
107
108
|
- lib/resque/helpers.rb
|
108
109
|
- lib/resque/job.rb
|
110
|
+
- lib/resque/plugin.rb
|
109
111
|
- lib/resque/server.rb
|
110
112
|
- lib/resque/server/public/idle.png
|
111
113
|
- lib/resque/server/public/jquery-1.3.2.min.js
|
@@ -134,6 +136,8 @@ files:
|
|
134
136
|
- tasks/redis.rake
|
135
137
|
- tasks/resque.rake
|
136
138
|
- test/job_hooks_test.rb
|
139
|
+
- test/job_plugins_test.rb
|
140
|
+
- test/plugin_test.rb
|
137
141
|
- test/redis-test.conf
|
138
142
|
- test/resque-web_test.rb
|
139
143
|
- test/resque_test.rb
|
@@ -166,9 +170,11 @@ rubyforge_project:
|
|
166
170
|
rubygems_version: 1.3.5
|
167
171
|
signing_key:
|
168
172
|
specification_version: 3
|
169
|
-
summary:
|
173
|
+
summary: Resque is a Redis-backed queueing system.
|
170
174
|
test_files:
|
171
175
|
- test/job_hooks_test.rb
|
176
|
+
- test/job_plugins_test.rb
|
177
|
+
- test/plugin_test.rb
|
172
178
|
- test/resque-web_test.rb
|
173
179
|
- test/resque_test.rb
|
174
180
|
- test/test_helper.rb
|