que 0.5.0 → 0.6.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/.gitignore +1 -1
- data/.travis.yml +1 -1
- data/CHANGELOG.md +21 -1
- data/Gemfile +5 -0
- data/README.md +7 -6
- data/docs/advanced_setup.md +14 -4
- data/docs/customizing_que.md +4 -4
- data/docs/error_handling.md +13 -1
- data/docs/managing_workers.md +2 -2
- data/docs/migrating.md +26 -0
- data/docs/multiple_queues.md +13 -0
- data/docs/shutting_down_safely.md +7 -0
- data/docs/writing_reliable_jobs.md +43 -0
- data/lib/generators/que/templates/add_que.rb +1 -1
- data/lib/que.rb +27 -41
- data/lib/que/adapters/base.rb +75 -4
- data/lib/que/job.rb +45 -28
- data/lib/que/migrations.rb +3 -2
- data/lib/que/migrations/{1-down.sql → 1/down.sql} +0 -0
- data/lib/que/migrations/{1-up.sql → 1/up.sql} +0 -0
- data/lib/que/migrations/{2-down.sql → 2/down.sql} +0 -0
- data/lib/que/migrations/{2-up.sql → 2/up.sql} +0 -0
- data/lib/que/migrations/3/down.sql +5 -0
- data/lib/que/migrations/3/up.sql +5 -0
- data/lib/que/sql.rb +24 -17
- data/lib/que/version.rb +1 -1
- data/lib/que/worker.rb +6 -5
- data/spec/adapters/active_record_spec.rb +6 -6
- data/spec/adapters/sequel_spec.rb +4 -4
- data/spec/gemfiles/Gemfile1 +18 -0
- data/spec/gemfiles/Gemfile2 +18 -0
- data/spec/support/helpers.rb +2 -1
- data/spec/support/shared_examples/adapter.rb +7 -3
- data/spec/support/shared_examples/multi_threaded_adapter.rb +2 -2
- data/spec/travis.rb +12 -4
- data/spec/unit/customization_spec.rb +148 -0
- data/spec/unit/{queue_spec.rb → enqueue_spec.rb} +115 -14
- data/spec/unit/logging_spec.rb +3 -2
- data/spec/unit/migrations_spec.rb +3 -2
- data/spec/unit/pool_spec.rb +30 -6
- data/spec/unit/run_spec.rb +12 -0
- data/spec/unit/states_spec.rb +29 -31
- data/spec/unit/stats_spec.rb +16 -14
- data/spec/unit/work_spec.rb +120 -25
- data/spec/unit/worker_spec.rb +55 -9
- data/tasks/safe_shutdown.rb +1 -1
- metadata +30 -17
data/spec/unit/worker_spec.rb
CHANGED
@@ -3,8 +3,8 @@ require 'spec_helper'
|
|
3
3
|
describe Que::Worker do
|
4
4
|
it "should work jobs when started until there are none available" do
|
5
5
|
begin
|
6
|
-
Que::Job.
|
7
|
-
Que::Job.
|
6
|
+
Que::Job.enqueue
|
7
|
+
Que::Job.enqueue
|
8
8
|
DB[:que_jobs].count.should be 2
|
9
9
|
|
10
10
|
@worker = Que::Worker.new
|
@@ -23,13 +23,59 @@ describe Que::Worker do
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
+
it "should work jobs without a named queue by default" do
|
27
|
+
begin
|
28
|
+
Que::Job.enqueue 1
|
29
|
+
Que::Job.enqueue 2, :queue => 'my_queue'
|
30
|
+
|
31
|
+
@worker = Que::Worker.new
|
32
|
+
sleep_until { @worker.sleeping? }
|
33
|
+
DB[:que_jobs].count.should be 1
|
34
|
+
|
35
|
+
$logger.messages.map{|m| JSON.load(m)['event']}.should == %w(job_worked job_unavailable)
|
36
|
+
|
37
|
+
json = JSON.load($logger.messages[0])
|
38
|
+
json['job']['queue'].should == ''
|
39
|
+
json['job']['job_class'].should == 'Que::Job'
|
40
|
+
json['job']['args'].should == [1]
|
41
|
+
ensure
|
42
|
+
if @worker
|
43
|
+
@worker.stop
|
44
|
+
@worker.wait_until_stopped
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should accept the name of a single queue to work jobs from" do
|
50
|
+
begin
|
51
|
+
Que::Job.enqueue 1
|
52
|
+
Que::Job.enqueue 2, :queue => 'my_queue'
|
53
|
+
|
54
|
+
@worker = Que::Worker.new(:my_queue)
|
55
|
+
sleep_until { @worker.sleeping? }
|
56
|
+
DB[:que_jobs].count.should be 1
|
57
|
+
|
58
|
+
$logger.messages.map{|m| JSON.load(m)['event']}.should == %w(job_worked job_unavailable)
|
59
|
+
|
60
|
+
json = JSON.load($logger.messages[0])
|
61
|
+
json['job']['queue'].should == 'my_queue'
|
62
|
+
json['job']['job_class'].should == 'Que::Job'
|
63
|
+
json['job']['args'].should == [2]
|
64
|
+
ensure
|
65
|
+
if @worker
|
66
|
+
@worker.stop
|
67
|
+
@worker.wait_until_stopped
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
26
72
|
it "#wake! should return truthy if the worker was asleep and is woken up, at which point it should work until no jobs are available" do
|
27
73
|
begin
|
28
74
|
@worker = Que::Worker.new
|
29
75
|
sleep_until { @worker.sleeping? }
|
30
76
|
|
31
|
-
Que::Job.
|
32
|
-
Que::Job.
|
77
|
+
Que::Job.enqueue
|
78
|
+
Que::Job.enqueue
|
33
79
|
DB[:que_jobs].count.should be 2
|
34
80
|
|
35
81
|
@worker.wake!.should be true
|
@@ -45,7 +91,7 @@ describe Que::Worker do
|
|
45
91
|
|
46
92
|
it "#wake! should return falsy if the worker was already working" do
|
47
93
|
begin
|
48
|
-
BlockJob.
|
94
|
+
BlockJob.enqueue
|
49
95
|
@worker = Que::Worker.new
|
50
96
|
|
51
97
|
$q1.pop
|
@@ -62,8 +108,8 @@ describe Que::Worker do
|
|
62
108
|
|
63
109
|
it "should not be deterred by a job that raises an error" do
|
64
110
|
begin
|
65
|
-
ErrorJob.
|
66
|
-
Que::Job.
|
111
|
+
ErrorJob.enqueue :priority => 1
|
112
|
+
Que::Job.enqueue :priority => 5
|
67
113
|
|
68
114
|
@worker = Que::Worker.new
|
69
115
|
|
@@ -89,8 +135,8 @@ describe Que::Worker do
|
|
89
135
|
|
90
136
|
it "should receive and respect a notification to stop down when it is working, after its current job completes" do
|
91
137
|
begin
|
92
|
-
BlockJob.
|
93
|
-
Que::Job.
|
138
|
+
BlockJob.enqueue :priority => 1
|
139
|
+
Que::Job.enqueue :priority => 5
|
94
140
|
DB[:que_jobs].count.should be 2
|
95
141
|
|
96
142
|
@worker = Que::Worker.new
|
data/tasks/safe_shutdown.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: que
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.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: 2014-
|
11
|
+
date: 2014-02-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.3'
|
20
20
|
type: :development
|
21
|
+
prerelease: false
|
21
22
|
version_requirements: !ruby/object:Gem::Requirement
|
22
23
|
requirements:
|
23
|
-
- -
|
24
|
+
- - ~>
|
24
25
|
- !ruby/object:Gem::Version
|
25
26
|
version: '1.3'
|
26
|
-
prerelease: false
|
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
|
@@ -31,9 +31,9 @@ executables: []
|
|
31
31
|
extensions: []
|
32
32
|
extra_rdoc_files: []
|
33
33
|
files:
|
34
|
-
-
|
35
|
-
-
|
36
|
-
-
|
34
|
+
- .gitignore
|
35
|
+
- .rspec
|
36
|
+
- .travis.yml
|
37
37
|
- CHANGELOG.md
|
38
38
|
- Gemfile
|
39
39
|
- LICENSE.txt
|
@@ -45,6 +45,9 @@ files:
|
|
45
45
|
- docs/inspecting_the_queue.md
|
46
46
|
- docs/logging.md
|
47
47
|
- docs/managing_workers.md
|
48
|
+
- docs/migrating.md
|
49
|
+
- docs/multiple_queues.md
|
50
|
+
- docs/shutting_down_safely.md
|
48
51
|
- docs/using_plain_connections.md
|
49
52
|
- docs/using_sequel.md
|
50
53
|
- docs/writing_reliable_jobs.md
|
@@ -58,10 +61,12 @@ files:
|
|
58
61
|
- lib/que/adapters/sequel.rb
|
59
62
|
- lib/que/job.rb
|
60
63
|
- lib/que/migrations.rb
|
61
|
-
- lib/que/migrations/1
|
62
|
-
- lib/que/migrations/1
|
63
|
-
- lib/que/migrations/2
|
64
|
-
- lib/que/migrations/2
|
64
|
+
- lib/que/migrations/1/down.sql
|
65
|
+
- lib/que/migrations/1/up.sql
|
66
|
+
- lib/que/migrations/2/down.sql
|
67
|
+
- lib/que/migrations/2/up.sql
|
68
|
+
- lib/que/migrations/3/down.sql
|
69
|
+
- lib/que/migrations/3/up.sql
|
65
70
|
- lib/que/railtie.rb
|
66
71
|
- lib/que/rake_tasks.rb
|
67
72
|
- lib/que/sql.rb
|
@@ -72,6 +77,8 @@ files:
|
|
72
77
|
- spec/adapters/connection_pool_spec.rb
|
73
78
|
- spec/adapters/pg_spec.rb
|
74
79
|
- spec/adapters/sequel_spec.rb
|
80
|
+
- spec/gemfiles/Gemfile1
|
81
|
+
- spec/gemfiles/Gemfile2
|
75
82
|
- spec/spec_helper.rb
|
76
83
|
- spec/support/helpers.rb
|
77
84
|
- spec/support/jobs.rb
|
@@ -79,11 +86,13 @@ files:
|
|
79
86
|
- spec/support/shared_examples/multi_threaded_adapter.rb
|
80
87
|
- spec/travis.rb
|
81
88
|
- spec/unit/connection_spec.rb
|
89
|
+
- spec/unit/customization_spec.rb
|
90
|
+
- spec/unit/enqueue_spec.rb
|
82
91
|
- spec/unit/helper_spec.rb
|
83
92
|
- spec/unit/logging_spec.rb
|
84
93
|
- spec/unit/migrations_spec.rb
|
85
94
|
- spec/unit/pool_spec.rb
|
86
|
-
- spec/unit/
|
95
|
+
- spec/unit/run_spec.rb
|
87
96
|
- spec/unit/states_spec.rb
|
88
97
|
- spec/unit/stats_spec.rb
|
89
98
|
- spec/unit/work_spec.rb
|
@@ -101,17 +110,17 @@ require_paths:
|
|
101
110
|
- lib
|
102
111
|
required_ruby_version: !ruby/object:Gem::Requirement
|
103
112
|
requirements:
|
104
|
-
- -
|
113
|
+
- - '>='
|
105
114
|
- !ruby/object:Gem::Version
|
106
115
|
version: '0'
|
107
116
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
117
|
requirements:
|
109
|
-
- -
|
118
|
+
- - '>='
|
110
119
|
- !ruby/object:Gem::Version
|
111
120
|
version: '0'
|
112
121
|
requirements: []
|
113
122
|
rubyforge_project:
|
114
|
-
rubygems_version: 2.
|
123
|
+
rubygems_version: 2.0.3
|
115
124
|
signing_key:
|
116
125
|
specification_version: 4
|
117
126
|
summary: A PostgreSQL-based Job Queue
|
@@ -120,6 +129,8 @@ test_files:
|
|
120
129
|
- spec/adapters/connection_pool_spec.rb
|
121
130
|
- spec/adapters/pg_spec.rb
|
122
131
|
- spec/adapters/sequel_spec.rb
|
132
|
+
- spec/gemfiles/Gemfile1
|
133
|
+
- spec/gemfiles/Gemfile2
|
123
134
|
- spec/spec_helper.rb
|
124
135
|
- spec/support/helpers.rb
|
125
136
|
- spec/support/jobs.rb
|
@@ -127,11 +138,13 @@ test_files:
|
|
127
138
|
- spec/support/shared_examples/multi_threaded_adapter.rb
|
128
139
|
- spec/travis.rb
|
129
140
|
- spec/unit/connection_spec.rb
|
141
|
+
- spec/unit/customization_spec.rb
|
142
|
+
- spec/unit/enqueue_spec.rb
|
130
143
|
- spec/unit/helper_spec.rb
|
131
144
|
- spec/unit/logging_spec.rb
|
132
145
|
- spec/unit/migrations_spec.rb
|
133
146
|
- spec/unit/pool_spec.rb
|
134
|
-
- spec/unit/
|
147
|
+
- spec/unit/run_spec.rb
|
135
148
|
- spec/unit/states_spec.rb
|
136
149
|
- spec/unit/stats_spec.rb
|
137
150
|
- spec/unit/work_spec.rb
|