resque-multi-step 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.md +117 -0
- data/Rakefile +72 -0
- data/VERSION +1 -0
- data/lib/resque/plugins/multi_step_task/assure_finalization.rb +15 -0
- data/lib/resque/plugins/multi_step_task/atomic_counters.rb +21 -0
- data/lib/resque/plugins/multi_step_task/constantization.rb +20 -0
- data/lib/resque/plugins/multi_step_task/finalization_job.rb +38 -0
- data/lib/resque/plugins/multi_step_task.rb +268 -0
- data/lib/resque-multi-step.rb +2 -0
- data/lib/resque_mutli_step.rb +1 -0
- data/resque-multi-step-task.gemspec +67 -0
- data/resque-multi-step.gemspec +81 -0
- data/spec/acceptance/acceptance_jobs.rb +31 -0
- data/spec/acceptance/job_handling_spec.rb +121 -0
- data/spec/acceptance/spec_helper.rb +13 -0
- data/spec/resque/plugins/multi_step_task/finalization_job_spec.rb +34 -0
- data/spec/resque/plugins/multi_step_task_spec.rb +235 -0
- data/spec/resque-multi-step_spec.rb +7 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +16 -0
- metadata +145 -0
@@ -0,0 +1,81 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{resque-multi-step}
|
8
|
+
s.version = "1.0.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Peter Williams", "Morgan Whitney"]
|
12
|
+
s.date = %q{2010-10-04}
|
13
|
+
s.description = %q{Provides multi-step tasks with finalization and progress tracking}
|
14
|
+
s.email = %q{pezra@barelyenough.org}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.md"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".gitignore",
|
22
|
+
"LICENSE",
|
23
|
+
"README.md",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION",
|
26
|
+
"lib/resque-multi-step.rb",
|
27
|
+
"lib/resque/plugins/multi_step_task.rb",
|
28
|
+
"lib/resque/plugins/multi_step_task/assure_finalization.rb",
|
29
|
+
"lib/resque/plugins/multi_step_task/atomic_counters.rb",
|
30
|
+
"lib/resque/plugins/multi_step_task/constantization.rb",
|
31
|
+
"lib/resque/plugins/multi_step_task/finalization_job.rb",
|
32
|
+
"lib/resque_mutli_step.rb",
|
33
|
+
"resque-multi-step-task.gemspec",
|
34
|
+
"resque-multi-step.gemspec",
|
35
|
+
"spec/acceptance/acceptance_jobs.rb",
|
36
|
+
"spec/acceptance/job_handling_spec.rb",
|
37
|
+
"spec/acceptance/spec_helper.rb",
|
38
|
+
"spec/resque-multi-step_spec.rb",
|
39
|
+
"spec/resque/plugins/multi_step_task/finalization_job_spec.rb",
|
40
|
+
"spec/resque/plugins/multi_step_task_spec.rb",
|
41
|
+
"spec/spec.opts",
|
42
|
+
"spec/spec_helper.rb"
|
43
|
+
]
|
44
|
+
s.homepage = %q{http://github.com/pezra/resque-multi-step}
|
45
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
46
|
+
s.require_paths = ["lib"]
|
47
|
+
s.rubygems_version = %q{1.3.6}
|
48
|
+
s.summary = %q{Provides multi-step tasks with finalization and progress tracking}
|
49
|
+
s.test_files = [
|
50
|
+
"spec/acceptance/acceptance_jobs.rb",
|
51
|
+
"spec/acceptance/job_handling_spec.rb",
|
52
|
+
"spec/acceptance/spec_helper.rb",
|
53
|
+
"spec/resque/plugins/multi_step_task/finalization_job_spec.rb",
|
54
|
+
"spec/resque/plugins/multi_step_task_spec.rb",
|
55
|
+
"spec/resque-multi-step_spec.rb",
|
56
|
+
"spec/spec_helper.rb"
|
57
|
+
]
|
58
|
+
|
59
|
+
if s.respond_to? :specification_version then
|
60
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
61
|
+
s.specification_version = 3
|
62
|
+
|
63
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
64
|
+
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
65
|
+
s.add_runtime_dependency(%q<redis-namespace>, ["~> 0.8.0"])
|
66
|
+
s.add_runtime_dependency(%q<resque>, ["~> 1.10"])
|
67
|
+
s.add_runtime_dependency(%q<resque-fairly>, ["~> 1.0"])
|
68
|
+
else
|
69
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
70
|
+
s.add_dependency(%q<redis-namespace>, ["~> 0.8.0"])
|
71
|
+
s.add_dependency(%q<resque>, ["~> 1.10"])
|
72
|
+
s.add_dependency(%q<resque-fairly>, ["~> 1.0"])
|
73
|
+
end
|
74
|
+
else
|
75
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
76
|
+
s.add_dependency(%q<redis-namespace>, ["~> 0.8.0"])
|
77
|
+
s.add_dependency(%q<resque>, ["~> 1.10"])
|
78
|
+
s.add_dependency(%q<resque-fairly>, ["~> 1.0"])
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module MultiStepAcceptance
|
2
|
+
class WaitJob
|
3
|
+
def self.perform(duration)
|
4
|
+
sleep duration
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
class CounterJob
|
9
|
+
def self.perform(key)
|
10
|
+
Resque.redis.incr key
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class FailJob
|
15
|
+
def self.perform
|
16
|
+
raise "boom"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class FailOnceJob
|
21
|
+
def self.perform(key)
|
22
|
+
if Resque.redis.exists(key)
|
23
|
+
return
|
24
|
+
else
|
25
|
+
Resque.redis.set(key, 'was here')
|
26
|
+
raise "boom"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,121 @@
|
|
1
|
+
require File.expand_path("spec_helper", File.dirname(__FILE__))
|
2
|
+
require 'resque/plugins/multi_step_task'
|
3
|
+
|
4
|
+
# These tests are inherently sensitive to timing. There are sleeps a
|
5
|
+
# the appropriate places to reduce/eliminate false failures where
|
6
|
+
# possible. However, a failure does not always indicate a bug. Run
|
7
|
+
# the test multiple times before accepting failures at face value.
|
8
|
+
|
9
|
+
describe "Acceptance: Successful task" do
|
10
|
+
let(:task) {
|
11
|
+
Resque::Plugins::MultiStepTask.create("testing") do |task|
|
12
|
+
task.add_job MultiStepAcceptance::CounterJob, "testing counter"
|
13
|
+
end
|
14
|
+
}
|
15
|
+
|
16
|
+
before do
|
17
|
+
Resque.redis.del "testing counter"
|
18
|
+
task
|
19
|
+
sleep 1
|
20
|
+
end
|
21
|
+
|
22
|
+
it "processes its job" do
|
23
|
+
Resque.redis.get("testing counter").to_i.should == 1
|
24
|
+
end
|
25
|
+
|
26
|
+
it "removes queue when done" do
|
27
|
+
Resque.queues.should_not include(task.queue_name)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "Acceptance: Successful tasks" do
|
32
|
+
let(:task) {
|
33
|
+
Resque::Plugins::MultiStepTask.create("testing") do |task|
|
34
|
+
task.add_job MultiStepAcceptance::WaitJob, 1
|
35
|
+
end
|
36
|
+
}
|
37
|
+
|
38
|
+
before {task}
|
39
|
+
|
40
|
+
it "create queue" do
|
41
|
+
Resque.queues.should include(task.queue_name)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "queues jobs in its queue" do
|
45
|
+
Resque.peek(task.queue_name).should_not be_nil
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "Acceptance: Task with step failure" do
|
51
|
+
let(:task) {
|
52
|
+
Resque::Plugins::MultiStepTask.create("testing") do |task|
|
53
|
+
task.add_job MultiStepAcceptance::FailJob
|
54
|
+
end
|
55
|
+
}
|
56
|
+
|
57
|
+
before do
|
58
|
+
Resque::Failure.clear
|
59
|
+
task
|
60
|
+
sleep 1
|
61
|
+
end
|
62
|
+
|
63
|
+
it "put job in fail list" do
|
64
|
+
Resque::Failure.count.should == 1
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
describe "Acceptance: Task with finalization failure" do
|
70
|
+
let(:task) {
|
71
|
+
Resque.redis.del "testing counter"
|
72
|
+
Resque::Plugins::MultiStepTask.create("testing") do |task|
|
73
|
+
task.add_finalization_job MultiStepAcceptance::FailJob
|
74
|
+
end
|
75
|
+
}
|
76
|
+
|
77
|
+
before do
|
78
|
+
Resque::Failure.clear
|
79
|
+
task
|
80
|
+
sleep 1
|
81
|
+
end
|
82
|
+
|
83
|
+
it "put job in fail list" do
|
84
|
+
5.times {sleep 1 if Resque::Failure.count < 1}
|
85
|
+
|
86
|
+
Resque::Failure.count.should == 1
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe "Acceptance: Task with retried finalization failure" do
|
91
|
+
let(:task) {
|
92
|
+
Resque.redis.del "testing counter"
|
93
|
+
Resque::Plugins::MultiStepTask.create("testing") do |task|
|
94
|
+
task.add_finalization_job MultiStepAcceptance::FailOnceJob, "fin-job"
|
95
|
+
task.add_finalization_job MultiStepAcceptance::CounterJob,"testing counter"
|
96
|
+
end
|
97
|
+
}
|
98
|
+
|
99
|
+
before do
|
100
|
+
Resque::Failure.clear
|
101
|
+
Resque.redis.del "testing counter"
|
102
|
+
|
103
|
+
task
|
104
|
+
sleep 1
|
105
|
+
|
106
|
+
Resque::Failure.requeue 0
|
107
|
+
sleep 1
|
108
|
+
end
|
109
|
+
|
110
|
+
it "completes task" do
|
111
|
+
lambda {
|
112
|
+
Resque::Plugins::MultiStepTask.find(task.task_id)
|
113
|
+
}.should raise_error(Resque::Plugins::MultiStepTask::NoSuchMultiStepTask)
|
114
|
+
end
|
115
|
+
|
116
|
+
|
117
|
+
it "runs following finalization jobs" do
|
118
|
+
Resque.redis.get("testing counter").to_i.should == 1
|
119
|
+
end
|
120
|
+
|
121
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require File.expand_path("../spec_helper", File.dirname(__FILE__))
|
2
|
+
|
3
|
+
$LOAD_PATH << File.dirname(__FILE__)
|
4
|
+
require 'acceptance_jobs'
|
5
|
+
|
6
|
+
$worker_pid = fork
|
7
|
+
if $worker_pid.nil?
|
8
|
+
# in child
|
9
|
+
exec "rake resque:work 'QUEUES=*' 'NAMESPACE=resque-multi-step-task-testing' INTERVAL=1 VERBOSE=1"
|
10
|
+
end
|
11
|
+
|
12
|
+
# wait for worker to come up
|
13
|
+
sleep 4
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require File.expand_path("../../../spec_helper", File.dirname(__FILE__))
|
2
|
+
|
3
|
+
module Resque::Plugins
|
4
|
+
class MultiStepTask
|
5
|
+
describe FinalizationJob do
|
6
|
+
let(:task){MultiStepTask.create("some-task")}
|
7
|
+
|
8
|
+
before do
|
9
|
+
task.finalizable!
|
10
|
+
end
|
11
|
+
|
12
|
+
it "queues next finalization job when done" do
|
13
|
+
Resque::Job.should_receive(:create).with(anything, Resque::Plugins::MultiStepTask::FinalizationJob, task.task_id, 'TestJob', 42)
|
14
|
+
|
15
|
+
task.add_finalization_job(TestJob, 42)
|
16
|
+
|
17
|
+
FinalizationJob.perform(task.task_id, 'TestJob', 0)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "cleans up on the last job" do
|
21
|
+
task.should_receive(:nuke)
|
22
|
+
MultiStepTask.stub!(:find).and_return(task)
|
23
|
+
|
24
|
+
FinalizationJob.perform(task.task_id, 'TestJob', 0)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
module ::TestJob
|
31
|
+
def self.perform(*args)
|
32
|
+
# no op
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,235 @@
|
|
1
|
+
require File.expand_path("../../spec_helper", File.dirname(__FILE__))
|
2
|
+
|
3
|
+
module Resque::Plugins
|
4
|
+
describe MultiStepTask, "class" do
|
5
|
+
it "allows creating new tasks" do
|
6
|
+
MultiStepTask.create("brand-new-task").should be_kind_of(MultiStepTask)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "allows creating new tasks with job specification block" do
|
10
|
+
MultiStepTask.create("brand-new-task") do |task|
|
11
|
+
task.add_job(TestJob)
|
12
|
+
end.should be_kind_of(MultiStepTask)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "uniquifies task queues when creating new task with same slug as and existing one" do
|
16
|
+
a = MultiStepTask.create("some-task")
|
17
|
+
b = MultiStepTask.create("some-task")
|
18
|
+
|
19
|
+
a.queue_name.should_not == b.queue_name
|
20
|
+
end
|
21
|
+
|
22
|
+
it "allows finding existing tasks" do
|
23
|
+
task_id = MultiStepTask.create("some-task").task_id
|
24
|
+
|
25
|
+
MultiStepTask.find(task_id).should be_kind_of(MultiStepTask)
|
26
|
+
MultiStepTask.find(task_id).task_id.should == task_id
|
27
|
+
end
|
28
|
+
|
29
|
+
it "raises exception on #find for non-existent task" do
|
30
|
+
lambda{
|
31
|
+
MultiStepTask.find('nonexistent-task')
|
32
|
+
}.should raise_error(MultiStepTask::NoSuchMultiStepTask)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "allows mode to be set to :sync" do
|
36
|
+
MultiStepTask.mode = :sync
|
37
|
+
MultiStepTask.should be_synchronous
|
38
|
+
end
|
39
|
+
|
40
|
+
it "allows mode to be set to :async" do
|
41
|
+
MultiStepTask.mode = :async
|
42
|
+
MultiStepTask.should_not be_synchronous
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe MultiStepTask do
|
47
|
+
let(:task) {MultiStepTask.create("some-task")}
|
48
|
+
|
49
|
+
it "allows jobs to be added to task" do
|
50
|
+
lambda {
|
51
|
+
task.add_job(TestJob)
|
52
|
+
}.should_not raise_error
|
53
|
+
end
|
54
|
+
|
55
|
+
it "queues added job" do
|
56
|
+
Resque::Job.should_receive(:create).with(task.queue_name, Resque::Plugins::MultiStepTask, task.task_id, 'TestJob')
|
57
|
+
task.add_job(TestJob)
|
58
|
+
end
|
59
|
+
|
60
|
+
it "allows finalization jobs to be added" do
|
61
|
+
task.add_finalization_job(TestJob)
|
62
|
+
end
|
63
|
+
|
64
|
+
it "allows itself to become finalizable" do
|
65
|
+
task.finalizable!
|
66
|
+
task.should be_finalizable
|
67
|
+
end
|
68
|
+
|
69
|
+
it "queues assure finalization job when it becomes finalizable" do
|
70
|
+
Resque::Job.should_receive(:create).with(task.queue_name, ::Resque::Plugins::MultiStepTask::AssureFinalization, task.task_id)
|
71
|
+
task.finalizable!
|
72
|
+
end
|
73
|
+
|
74
|
+
it "knows total job count" do
|
75
|
+
task.add_job(TestJob)
|
76
|
+
|
77
|
+
task.total_job_count.should == 1
|
78
|
+
end
|
79
|
+
|
80
|
+
it "includes finalization jobs in total job count" do
|
81
|
+
task.add_job(TestJob)
|
82
|
+
task.add_finalization_job(TestJob, "my", "args")
|
83
|
+
|
84
|
+
task.total_job_count.should == 2
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
describe MultiStepTask, "synchronous mode" do
|
89
|
+
let(:task){MultiStepTask.create("some-task")}
|
90
|
+
|
91
|
+
before do
|
92
|
+
MultiStepTask.mode = :sync
|
93
|
+
end
|
94
|
+
|
95
|
+
after do
|
96
|
+
MultiStepTask.mode = :async
|
97
|
+
end
|
98
|
+
|
99
|
+
it "runs job when added" do
|
100
|
+
TestJob.should_receive(:perform).with("my", "args")
|
101
|
+
task.add_job(TestJob, "my", "args")
|
102
|
+
end
|
103
|
+
|
104
|
+
it "runs finalization job when added" do
|
105
|
+
TestJob.should_receive(:perform).with("my", "args")
|
106
|
+
task.add_finalization_job(TestJob, "my", "args")
|
107
|
+
task.finalizable!
|
108
|
+
end
|
109
|
+
|
110
|
+
it "runs finalization jobs last" do
|
111
|
+
TestJob.should_receive(:perform).with("my", "args").ordered
|
112
|
+
MyFinalJob.should_receive(:perform).with("final", "args").ordered
|
113
|
+
|
114
|
+
task.add_finalization_job(MyFinalJob, "final", "args")
|
115
|
+
task.add_job(TestJob, "my", "args")
|
116
|
+
task.finalizable!
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
describe MultiStepTask, "finalization" do
|
121
|
+
let(:task){MultiStepTask.create("some-task")}
|
122
|
+
|
123
|
+
before do
|
124
|
+
task.finalizable!
|
125
|
+
end
|
126
|
+
|
127
|
+
it "queue finalization jobs" do
|
128
|
+
Resque::Job.should_receive(:create).with(anything, Resque::Plugins::MultiStepTask::FinalizationJob, task.task_id, 'TestJob', 42)
|
129
|
+
|
130
|
+
task.add_finalization_job(TestJob, 42)
|
131
|
+
task.finalize!
|
132
|
+
end
|
133
|
+
|
134
|
+
it "initiates finalization at end of last job" do
|
135
|
+
task.add_finalization_job(TestJob, 42)
|
136
|
+
|
137
|
+
Resque::Job.should_receive(:create).with(anything, Resque::Plugins::MultiStepTask::FinalizationJob, task.task_id, 'TestJob', 42)
|
138
|
+
Resque::Job.reserve(task.queue_name).perform
|
139
|
+
end
|
140
|
+
|
141
|
+
it "removes queue from resque" do
|
142
|
+
task.add_job(TestJob) # creates queue
|
143
|
+
MultiStepTask.perform(task.task_id, 'TestJob') # simulate runing final job
|
144
|
+
|
145
|
+
Resque.queues.should_not include(task.task_id)
|
146
|
+
end
|
147
|
+
|
148
|
+
it "fails if finalization has already been run" do
|
149
|
+
task.finalize!
|
150
|
+
lambda{task.finalize!}.should raise_error(::Resque::Plugins::MultiStepTask::FinalizationAlreadyBegun)
|
151
|
+
end
|
152
|
+
|
153
|
+
it "fails if task is not yet finalizable" do
|
154
|
+
task = MultiStepTask.create("some-task")
|
155
|
+
lambda{task.finalize!}.should raise_error(::Resque::Plugins::MultiStepTask::NotReadyForFinalization)
|
156
|
+
end
|
157
|
+
|
158
|
+
it "fails if task has errors" do
|
159
|
+
TestJob.should_receive(:perform).and_raise('boo')
|
160
|
+
task = MultiStepTask.create("some-task")
|
161
|
+
MultiStepTask.perform(task.task_id, 'TestJob') rescue nil
|
162
|
+
|
163
|
+
lambda{task.finalize!}.should raise_error(::Resque::Plugins::MultiStepTask::NotReadyForFinalization)
|
164
|
+
end
|
165
|
+
|
166
|
+
end
|
167
|
+
|
168
|
+
describe MultiStepTask, "performing job" do
|
169
|
+
let(:task){MultiStepTask.create("some-task")}
|
170
|
+
|
171
|
+
it "invokes specified job when #perform is called" do
|
172
|
+
TestJob.should_receive(:perform).with(42, 'aaa')
|
173
|
+
|
174
|
+
MultiStepTask.perform(task.task_id, 'TestJob', 42, 'aaa')
|
175
|
+
end
|
176
|
+
|
177
|
+
it "increments completed count on job success" do
|
178
|
+
lambda{
|
179
|
+
MultiStepTask.perform(task.task_id, 'TestJob', 42, 'aaa')
|
180
|
+
}.should change(task, :completed_count).by(1)
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
describe MultiStepTask, "performing job that fails" do
|
185
|
+
let(:task){MultiStepTask.create("some-task")}
|
186
|
+
|
187
|
+
before do
|
188
|
+
TestJob.should_receive(:perform).and_raise('boo')
|
189
|
+
end
|
190
|
+
|
191
|
+
it "increments failed count" do
|
192
|
+
lambda{
|
193
|
+
MultiStepTask.perform(task.task_id, 'TestJob', 42, 'aaa') rescue nil
|
194
|
+
}.should change(task, :failed_count).by(1)
|
195
|
+
end
|
196
|
+
|
197
|
+
it "does not increment completed count" do
|
198
|
+
lambda{
|
199
|
+
MultiStepTask.perform(task.task_id, 'TestJob', 42, 'aaa') rescue nil
|
200
|
+
}.should_not change(task, :completed_count).by(1)
|
201
|
+
end
|
202
|
+
|
203
|
+
it "bubbles raised exception job up to resque" do
|
204
|
+
lambda{
|
205
|
+
MultiStepTask.perform(task.task_id, 'TestJob', 42, 'aaa')
|
206
|
+
}.should raise_exception("boo")
|
207
|
+
end
|
208
|
+
|
209
|
+
it "knows it is incomplete because of failures" do
|
210
|
+
task.increment_normal_job_count
|
211
|
+
MultiStepTask.perform(task.task_id, 'TestJob', 42, 'aaa') rescue nil
|
212
|
+
|
213
|
+
task.should be_incomplete_because_of_errors
|
214
|
+
end
|
215
|
+
|
216
|
+
it "knows it is complete when failures have occurred and have been retried successfully" do
|
217
|
+
MultiStepTask.perform(task.task_id, 'TestJob', 42, 'aaa') rescue nil
|
218
|
+
|
219
|
+
task.should_not be_incomplete_because_of_errors
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
module ::TestJob
|
225
|
+
def self.perform(*args)
|
226
|
+
# no op
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
module ::MyFinalJob
|
231
|
+
def self.perform(*args)
|
232
|
+
# no op
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--format=specdoc
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
+
require 'resque-multi-step'
|
4
|
+
require 'spec'
|
5
|
+
require 'spec/autorun'
|
6
|
+
require 'pp'
|
7
|
+
|
8
|
+
Spec::Runner.configure do |config|
|
9
|
+
config.before do
|
10
|
+
# Tests are jailed to a testing namespace and that space does
|
11
|
+
# contains in left over data from previous runs.
|
12
|
+
Resque.redis.namespace = "resque-multi-step-task-testing"
|
13
|
+
Resque.redis.keys('*').each{|k| Resque.redis.del k}
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,145 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: resque-multi-step
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 1
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
version: 1.0.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Peter Williams
|
13
|
+
- Morgan Whitney
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-10-04 00:00:00 -06:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: rspec
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 1
|
30
|
+
- 2
|
31
|
+
- 9
|
32
|
+
version: 1.2.9
|
33
|
+
type: :development
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: redis-namespace
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ~>
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
segments:
|
43
|
+
- 0
|
44
|
+
- 8
|
45
|
+
- 0
|
46
|
+
version: 0.8.0
|
47
|
+
type: :runtime
|
48
|
+
version_requirements: *id002
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: resque
|
51
|
+
prerelease: false
|
52
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ~>
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
segments:
|
57
|
+
- 1
|
58
|
+
- 10
|
59
|
+
version: "1.10"
|
60
|
+
type: :runtime
|
61
|
+
version_requirements: *id003
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: resque-fairly
|
64
|
+
prerelease: false
|
65
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
segments:
|
70
|
+
- 1
|
71
|
+
- 0
|
72
|
+
version: "1.0"
|
73
|
+
type: :runtime
|
74
|
+
version_requirements: *id004
|
75
|
+
description: Provides multi-step tasks with finalization and progress tracking
|
76
|
+
email: pezra@barelyenough.org
|
77
|
+
executables: []
|
78
|
+
|
79
|
+
extensions: []
|
80
|
+
|
81
|
+
extra_rdoc_files:
|
82
|
+
- LICENSE
|
83
|
+
- README.md
|
84
|
+
files:
|
85
|
+
- .document
|
86
|
+
- .gitignore
|
87
|
+
- LICENSE
|
88
|
+
- README.md
|
89
|
+
- Rakefile
|
90
|
+
- VERSION
|
91
|
+
- lib/resque-multi-step.rb
|
92
|
+
- lib/resque/plugins/multi_step_task.rb
|
93
|
+
- lib/resque/plugins/multi_step_task/assure_finalization.rb
|
94
|
+
- lib/resque/plugins/multi_step_task/atomic_counters.rb
|
95
|
+
- lib/resque/plugins/multi_step_task/constantization.rb
|
96
|
+
- lib/resque/plugins/multi_step_task/finalization_job.rb
|
97
|
+
- lib/resque_mutli_step.rb
|
98
|
+
- resque-multi-step-task.gemspec
|
99
|
+
- resque-multi-step.gemspec
|
100
|
+
- spec/acceptance/acceptance_jobs.rb
|
101
|
+
- spec/acceptance/job_handling_spec.rb
|
102
|
+
- spec/acceptance/spec_helper.rb
|
103
|
+
- spec/resque-multi-step_spec.rb
|
104
|
+
- spec/resque/plugins/multi_step_task/finalization_job_spec.rb
|
105
|
+
- spec/resque/plugins/multi_step_task_spec.rb
|
106
|
+
- spec/spec.opts
|
107
|
+
- spec/spec_helper.rb
|
108
|
+
has_rdoc: true
|
109
|
+
homepage: http://github.com/pezra/resque-multi-step
|
110
|
+
licenses: []
|
111
|
+
|
112
|
+
post_install_message:
|
113
|
+
rdoc_options:
|
114
|
+
- --charset=UTF-8
|
115
|
+
require_paths:
|
116
|
+
- lib
|
117
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
segments:
|
122
|
+
- 0
|
123
|
+
version: "0"
|
124
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
segments:
|
129
|
+
- 0
|
130
|
+
version: "0"
|
131
|
+
requirements: []
|
132
|
+
|
133
|
+
rubyforge_project:
|
134
|
+
rubygems_version: 1.3.6
|
135
|
+
signing_key:
|
136
|
+
specification_version: 3
|
137
|
+
summary: Provides multi-step tasks with finalization and progress tracking
|
138
|
+
test_files:
|
139
|
+
- spec/acceptance/acceptance_jobs.rb
|
140
|
+
- spec/acceptance/job_handling_spec.rb
|
141
|
+
- spec/acceptance/spec_helper.rb
|
142
|
+
- spec/resque/plugins/multi_step_task/finalization_job_spec.rb
|
143
|
+
- spec/resque/plugins/multi_step_task_spec.rb
|
144
|
+
- spec/resque-multi-step_spec.rb
|
145
|
+
- spec/spec_helper.rb
|