que 0.10.0 → 0.11.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -0
- data/README.md +16 -9
- data/bin/que +85 -0
- data/docs/advanced_setup.md +53 -36
- data/docs/customizing_que.md +141 -78
- data/docs/error_handling.md +34 -30
- data/docs/inspecting_the_queue.md +66 -52
- data/docs/logging.md +30 -18
- data/docs/managing_workers.md +32 -16
- data/docs/migrating.md +18 -14
- data/docs/multiple_queues.md +15 -9
- data/docs/using_plain_connections.md +38 -32
- data/docs/using_sequel.md +20 -16
- data/docs/writing_reliable_jobs.md +68 -56
- data/lib/que/adapters/active_record.rb +14 -0
- data/lib/que/adapters/base.rb +7 -21
- data/lib/que/job.rb +52 -47
- data/lib/que/railtie.rb +4 -19
- data/lib/que/rake_tasks.rb +1 -0
- data/lib/que/sql.rb +45 -6
- data/lib/que/version.rb +1 -1
- data/lib/que/worker.rb +2 -1
- data/lib/que.rb +48 -2
- data/que.gemspec +1 -1
- data/spec/adapters/active_record_spec.rb +31 -4
- data/spec/unit/customization_spec.rb +61 -0
- data/spec/unit/pool_spec.rb +3 -3
- data/spec/unit/work_spec.rb +18 -0
- metadata +6 -4
@@ -185,4 +185,65 @@ describe "Customizing Que" do
|
|
185
185
|
end
|
186
186
|
end
|
187
187
|
end
|
188
|
+
|
189
|
+
describe "not retrying specific failed jobs" do
|
190
|
+
before do
|
191
|
+
Que.execute "CREATE TABLE failed_jobs AS SELECT * FROM que_jobs LIMIT 0"
|
192
|
+
end
|
193
|
+
|
194
|
+
after do
|
195
|
+
DB.drop_table? :failed_jobs
|
196
|
+
end
|
197
|
+
|
198
|
+
it "should be easily achievable with a module" do
|
199
|
+
begin
|
200
|
+
module SkipRetries
|
201
|
+
def run(*args)
|
202
|
+
super
|
203
|
+
rescue
|
204
|
+
sql = <<-SQL
|
205
|
+
WITH failed AS (
|
206
|
+
DELETE
|
207
|
+
FROM que_jobs
|
208
|
+
WHERE queue = $1::text
|
209
|
+
AND priority = $2::smallint
|
210
|
+
AND run_at = $3::timestamptz
|
211
|
+
AND job_id = $4::bigint
|
212
|
+
RETURNING *
|
213
|
+
)
|
214
|
+
INSERT INTO failed_jobs
|
215
|
+
SELECT * FROM failed;
|
216
|
+
SQL
|
217
|
+
|
218
|
+
Que.execute sql, @attrs.values_at(:queue, :priority, :run_at, :job_id)
|
219
|
+
|
220
|
+
raise
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
class SkipRetryJob < Que::Job
|
225
|
+
prepend SkipRetries
|
226
|
+
|
227
|
+
def run(*args)
|
228
|
+
$retry_job_args = args
|
229
|
+
raise "Fail!"
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
SkipRetryJob.enqueue 1, 'arg1', :other_arg => 'blah'
|
234
|
+
Que::Job.work
|
235
|
+
|
236
|
+
$retry_job_args.should == [1, 'arg1', {'other_arg' => 'blah'}]
|
237
|
+
|
238
|
+
DB[:que_jobs].count.should == 0
|
239
|
+
DB[:failed_jobs].count.should == 1
|
240
|
+
|
241
|
+
job = DB[:failed_jobs].first
|
242
|
+
JSON.parse(job[:args]).should == [1, 'arg1', {'other_arg' => 'blah'}]
|
243
|
+
job[:job_class].should == 'SkipRetryJob'
|
244
|
+
ensure
|
245
|
+
$retry_job_args = nil
|
246
|
+
end
|
247
|
+
end
|
248
|
+
end
|
188
249
|
end
|
data/spec/unit/pool_spec.rb
CHANGED
@@ -103,12 +103,12 @@ describe "Managing the Worker pool" do
|
|
103
103
|
sleep_until { DB[:que_jobs].count == 0 }
|
104
104
|
end
|
105
105
|
|
106
|
-
it "should work jobs in the queue defined by
|
106
|
+
it "should work jobs in the queue defined by the Que.queue_name config option" do
|
107
107
|
begin
|
108
108
|
Que::Job.enqueue 1
|
109
109
|
Que::Job.enqueue 2, :queue => 'my_queue'
|
110
110
|
|
111
|
-
|
111
|
+
Que.queue_name = 'my_queue'
|
112
112
|
|
113
113
|
Que.mode = :async
|
114
114
|
Que.worker_count = 2
|
@@ -120,7 +120,7 @@ describe "Managing the Worker pool" do
|
|
120
120
|
job[:queue].should == ''
|
121
121
|
job[:args].should == '[1]'
|
122
122
|
ensure
|
123
|
-
|
123
|
+
Que.queue_name = nil
|
124
124
|
end
|
125
125
|
end
|
126
126
|
end
|
data/spec/unit/work_spec.rb
CHANGED
@@ -14,6 +14,24 @@ describe Que::Job, '.work' do
|
|
14
14
|
$passed_args.should == [1, 'two', {'three' => 3}]
|
15
15
|
end
|
16
16
|
|
17
|
+
it "should respect a custom json converter when processing the job's arguments" do
|
18
|
+
ArgsJob.enqueue 1, 'two', {'three' => 3}
|
19
|
+
DB[:que_jobs].count.should be 1
|
20
|
+
|
21
|
+
begin
|
22
|
+
Que.json_converter = Que::SYMBOLIZER
|
23
|
+
|
24
|
+
result = Que::Job.work
|
25
|
+
result[:event].should == :job_worked
|
26
|
+
result[:job][:job_class].should == 'ArgsJob'
|
27
|
+
|
28
|
+
DB[:que_jobs].count.should be 0
|
29
|
+
$passed_args.should == [1, 'two', {:three => 3}]
|
30
|
+
ensure
|
31
|
+
Que.json_converter = Que::INDIFFERENTIATOR
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
17
35
|
it "should default to only working jobs without a named queue" do
|
18
36
|
Que::Job.enqueue 1, :queue => 'other_queue'
|
19
37
|
Que::Job.enqueue 2
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: que
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Hanks
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -27,7 +27,8 @@ dependencies:
|
|
27
27
|
description: A job queue that uses PostgreSQL's advisory locks for speed and reliability.
|
28
28
|
email:
|
29
29
|
- christopher.m.hanks@gmail.com
|
30
|
-
executables:
|
30
|
+
executables:
|
31
|
+
- que
|
31
32
|
extensions: []
|
32
33
|
extra_rdoc_files: []
|
33
34
|
files:
|
@@ -39,6 +40,7 @@ files:
|
|
39
40
|
- LICENSE.txt
|
40
41
|
- README.md
|
41
42
|
- Rakefile
|
43
|
+
- bin/que
|
42
44
|
- docs/advanced_setup.md
|
43
45
|
- docs/customizing_que.md
|
44
46
|
- docs/error_handling.md
|
@@ -123,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
125
|
version: '0'
|
124
126
|
requirements: []
|
125
127
|
rubyforge_project:
|
126
|
-
rubygems_version: 2.4.
|
128
|
+
rubygems_version: 2.4.8
|
127
129
|
signing_key:
|
128
130
|
specification_version: 4
|
129
131
|
summary: A PostgreSQL-based Job Queue
|