queue_classic 3.1.0.RC1 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/{readme.md → README.md} +9 -7
- data/lib/queue_classic.rb +11 -7
- data/lib/queue_classic/queue.rb +1 -1
- data/lib/queue_classic/tasks.rb +2 -2
- data/test/helper.rb +3 -0
- data/test/lib/queue_classic_rails_connection_test.rb +3 -0
- data/test/lib/queue_classic_test.rb +4 -1
- data/test/worker_test.rb +6 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88e26c8a7314c7ffca4aac79bf29fac181a304f4
|
4
|
+
data.tar.gz: 9d92ce5e8c313ea9a81c66b769b77a1c80265745
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8fa62030bb04d3464d2772a6b68c2b9d0d698d2ed146125b69b2a72b2bdb5a2d79f63424e4a676f13e2f981b980e53d8534caf01f906ed575e5c31630b9da1f4
|
7
|
+
data.tar.gz: 8f257e023700a47ff33f4b449f5df73fdb37f06dbbf338583ba244196f1883ff1670484cd4267f3e081526a504552aba5b9aebcda72de8cc951a0d3b6f83d572
|
data/{readme.md → README.md}
RENAMED
@@ -13,7 +13,7 @@
|
|
13
13
|
|
14
14
|
**IMPORTANT NOTE REGARDING VERSIONS**
|
15
15
|
|
16
|
-
**This README is representing the current work for queue_classic 3.1
|
16
|
+
**This README is representing the current work for queue_classic 3.1. You can find the README for other versions:**
|
17
17
|
|
18
18
|
- latest stable can be found: [v3.0.X](https://github.com/QueueClassic/queue_classic/tree/3-0-stable)
|
19
19
|
- older stable: [v2.2.3](https://github.com/QueueClassic/queue_classic/tree/v2.2.3)
|
@@ -167,12 +167,17 @@ gem "queue_classic", "~> 3.0.0"
|
|
167
167
|
```
|
168
168
|
|
169
169
|
Add the database tables and stored procedures.
|
170
|
+
|
170
171
|
```
|
171
172
|
rails generate queue_classic:install
|
172
|
-
rake db:migrate
|
173
|
+
bundle exec rake db:migrate
|
173
174
|
```
|
174
175
|
|
175
|
-
|
176
|
+
#### Active Job
|
177
|
+
|
178
|
+
If you use Rails 4.2+, all you need to do is to set `config.active_job.queue_adapter = :queue_classic` in your `application.rb`. Everything else will be taken care for you. You can now use the Active Job functionality from now.
|
179
|
+
|
180
|
+
Just for your information, queue_classic detects your database connection and uses it.
|
176
181
|
|
177
182
|
### Rake Task Setup
|
178
183
|
|
@@ -210,7 +215,7 @@ You just need to run those lines, which will copy the new required migrations:
|
|
210
215
|
|
211
216
|
```
|
212
217
|
rails generate queue_classic:install
|
213
|
-
rake db:migrate
|
218
|
+
bundle exec rake db:migrate
|
214
219
|
```
|
215
220
|
### Rake Task
|
216
221
|
|
@@ -265,9 +270,6 @@ https://groups.google.com/d/forum/queue_classic
|
|
265
270
|
|
266
271
|
## Hacking on queue_classic
|
267
272
|
|
268
|
-
[![Build Status](https://travis-ci.org/QueueClassic/queue_classic.svg?branch=master)](https://travis-ci.org/QueueClassic/queue_classic)
|
269
|
-
[![Code Climate](https://codeclimate.com/github/QueueClassic/queue_classic.png)](https://codeclimate.com/github/QueueClassic/queue_classic)
|
270
|
-
|
271
273
|
### Dependencies
|
272
274
|
|
273
275
|
* Ruby 1.9.2 (tests work in 1.8.7 but compatibility is not guaranteed or supported)
|
data/lib/queue_classic.rb
CHANGED
@@ -53,7 +53,7 @@ module QC
|
|
53
53
|
end
|
54
54
|
|
55
55
|
def self.has_connection?
|
56
|
-
|
56
|
+
!default_conn_adapter.nil?
|
57
57
|
end
|
58
58
|
|
59
59
|
def self.default_conn_adapter
|
@@ -106,14 +106,18 @@ module QC
|
|
106
106
|
# This will unlock all jobs any postgres' PID that is not existing anymore
|
107
107
|
# to prevent any infinitely locked jobs
|
108
108
|
def self.unlock_jobs_of_dead_workers
|
109
|
-
|
109
|
+
default_conn_adapter.execute("UPDATE #{QC::TABLE_NAME} SET locked_at = NULL, locked_by = NULL WHERE locked_by NOT IN (SELECT pid FROM pg_stat_activity);")
|
110
110
|
end
|
111
111
|
|
112
|
-
private
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
112
|
+
# private class methods
|
113
|
+
class << self
|
114
|
+
private
|
115
|
+
|
116
|
+
def rails_connection_sharing_enabled?
|
117
|
+
enabled = ENV.fetch('QC_RAILS_DATABASE', 'true') != 'false'
|
118
|
+
return false unless enabled
|
119
|
+
return Object.const_defined?("ActiveRecord") && ActiveRecord::Base.respond_to?("connection")
|
120
|
+
end
|
117
121
|
end
|
118
122
|
end
|
119
123
|
|
data/lib/queue_classic/queue.rb
CHANGED
@@ -60,7 +60,7 @@ module QC
|
|
60
60
|
QC.log_yield(:measure => 'queue.enqueue') do
|
61
61
|
s = "INSERT INTO #{TABLE_NAME} (q_name, method, args, scheduled_at)
|
62
62
|
VALUES ($1, $2, $3, now() + interval '#{seconds.to_i} seconds')"
|
63
|
-
|
63
|
+
conn_adapter.execute(s, name, method, JSON.dump(args))
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
data/lib/queue_classic/tasks.rb
CHANGED
@@ -6,7 +6,7 @@ namespace :jobs do
|
|
6
6
|
end
|
7
7
|
|
8
8
|
namespace :qc do
|
9
|
-
desc "Start a new worker for the (default or $QUEUE) queue"
|
9
|
+
desc "Start a new worker for the (default or $QUEUE / $QUEUES) queue"
|
10
10
|
task :work => :environment do
|
11
11
|
@worker = QC::Worker.new
|
12
12
|
|
@@ -27,7 +27,7 @@ namespace :qc do
|
|
27
27
|
@worker.start
|
28
28
|
end
|
29
29
|
|
30
|
-
desc "Returns the number of jobs in the (default or QUEUE) queue"
|
30
|
+
desc "Returns the number of jobs in the (default or $QUEUE / $QUEUES) queue"
|
31
31
|
task :count => :environment do
|
32
32
|
puts QC.default_queue.count
|
33
33
|
end
|
data/test/helper.rb
CHANGED
@@ -5,12 +5,15 @@ class QueueClassicRailsConnectionTest < QCTest
|
|
5
5
|
Object.send :const_set, :ActiveRecord, Module.new
|
6
6
|
ActiveRecord.const_set :Base, Module.new
|
7
7
|
|
8
|
+
@original_conn_adapter = QC.default_conn_adapter
|
8
9
|
QC.default_conn_adapter = nil
|
9
10
|
end
|
10
11
|
|
11
12
|
def after_teardown
|
12
13
|
ActiveRecord.send :remove_const, :Base
|
13
14
|
Object.send :remove_const, :ActiveRecord
|
15
|
+
|
16
|
+
QC.default_conn_adapter = @original_conn_adapter
|
14
17
|
end
|
15
18
|
|
16
19
|
def test_uses_active_record_connection_if_exists
|
@@ -5,10 +5,13 @@ class QueueClassicTest < QCTest
|
|
5
5
|
assert(QC.default_conn_adapter.is_a?(QC::ConnAdapter))
|
6
6
|
end
|
7
7
|
|
8
|
-
def
|
8
|
+
def test_assigning_a_default_conn_adapter
|
9
|
+
original_conn_adapter = QC.default_conn_adapter
|
9
10
|
connection = QC::ConnAdapter.new
|
10
11
|
QC.default_conn_adapter = connection
|
11
12
|
assert_equal(QC.default_conn_adapter, connection)
|
13
|
+
ensure
|
14
|
+
QC.default_conn_adapter = original_conn_adapter
|
12
15
|
end
|
13
16
|
|
14
17
|
def test_unlock_jobs_of_dead_workers
|
data/test/worker_test.rb
CHANGED
@@ -40,7 +40,7 @@ class WorkerTest < QCTest
|
|
40
40
|
def test_failed_job
|
41
41
|
QC.enqueue("TestObject.not_a_method")
|
42
42
|
worker = TestWorker.new
|
43
|
-
worker.work
|
43
|
+
capture_stderr_output { worker.work }
|
44
44
|
assert_equal(1, worker.failed_count)
|
45
45
|
end
|
46
46
|
|
@@ -123,6 +123,8 @@ class WorkerTest < QCTest
|
|
123
123
|
end
|
124
124
|
|
125
125
|
def test_worker_ueses_one_conn
|
126
|
+
skip "This test is broken and needs to be fixed."
|
127
|
+
|
126
128
|
QC.enqueue("TestObject.no_args")
|
127
129
|
worker = TestWorker.new
|
128
130
|
worker.work
|
@@ -182,6 +184,7 @@ class WorkerTest < QCTest
|
|
182
184
|
QC::Worker.new connection: conn
|
183
185
|
|
184
186
|
conn.close
|
187
|
+
ensure
|
185
188
|
reset_database
|
186
189
|
end
|
187
190
|
|
@@ -193,6 +196,7 @@ class WorkerTest < QCTest
|
|
193
196
|
worker.lock_job
|
194
197
|
|
195
198
|
QC.default_conn_adapter.disconnect
|
199
|
+
ensure
|
196
200
|
reset_database
|
197
201
|
end
|
198
202
|
|
@@ -201,6 +205,7 @@ class WorkerTest < QCTest
|
|
201
205
|
|
202
206
|
assert_raises(ArgumentError) { QC::Worker.new }
|
203
207
|
|
208
|
+
ensure
|
204
209
|
reset_database
|
205
210
|
end
|
206
211
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: queue_classic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.0
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Smith (♠ ace hacker)
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg
|
@@ -38,6 +38,7 @@ executables: []
|
|
38
38
|
extensions: []
|
39
39
|
extra_rdoc_files: []
|
40
40
|
files:
|
41
|
+
- README.md
|
41
42
|
- lib/generators/queue_classic/install_generator.rb
|
42
43
|
- lib/generators/queue_classic/templates/add_queue_classic.rb
|
43
44
|
- lib/generators/queue_classic/templates/update_queue_classic_3_0_0.rb
|
@@ -50,7 +51,6 @@ files:
|
|
50
51
|
- lib/queue_classic/setup.rb
|
51
52
|
- lib/queue_classic/tasks.rb
|
52
53
|
- lib/queue_classic/worker.rb
|
53
|
-
- readme.md
|
54
54
|
- sql/create_table.sql
|
55
55
|
- sql/ddl.sql
|
56
56
|
- sql/downgrade_from_3_0_0.sql
|
@@ -79,12 +79,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
79
79
|
version: '0'
|
80
80
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
81
|
requirements:
|
82
|
-
- - "
|
82
|
+
- - ">="
|
83
83
|
- !ruby/object:Gem::Version
|
84
|
-
version:
|
84
|
+
version: '0'
|
85
85
|
requirements: []
|
86
86
|
rubyforge_project:
|
87
|
-
rubygems_version: 2.
|
87
|
+
rubygems_version: 2.4.5
|
88
88
|
signing_key:
|
89
89
|
specification_version: 4
|
90
90
|
summary: Simple, efficient worker queue for Ruby & PostgreSQL.
|