que 0.8.1 → 0.8.2
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 +4 -0
- data/docs/advanced_setup.md +12 -1
- data/lib/que/adapters/active_record.rb +7 -3
- data/lib/que/job.rb +1 -1
- data/lib/que/version.rb +1 -1
- data/lib/que/worker.rb +4 -4
- data/lib/que.rb +1 -1
- data/spec/adapters/active_record_spec.rb +12 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8029277244c5b5f8e4d838c9e16b2ebddd402919
|
4
|
+
data.tar.gz: 06fe39d7feb085098468d4b7f019aa0a40433016
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3564b06d93c6001367f7d728e6ba22600abe53609a6551bc73aac2dda6cd6ab55629e12b002adb9998981960358617f8b0fd045d5ee9367ef52e1fd371dfb654
|
7
|
+
data.tar.gz: 2f7731e0b01ffed874937273c86364f7a19bd6de67a573f8c82aedf1dcc5918e6c841ae1b78dbbd90c085f9f5112c5440551f72f4738081ec9c24a1b8f49aae7
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
### 0.8.2 (2014-10-12)
|
2
|
+
|
3
|
+
* Fix errors raised during rollbacks in the ActiveRecord adapter, which remained silent until Rails 4.2. (#64, #65) (Strech)
|
4
|
+
|
1
5
|
### 0.8.1 (2014-07-28)
|
2
6
|
|
3
7
|
* Fix regression introduced in the `que:work` rake task by the `mode` / `worker_count` disentangling in 0.8.0. (#50)
|
data/docs/advanced_setup.md
CHANGED
@@ -20,7 +20,7 @@ There are other docs to read if you're using [Sequel](https://github.com/chanks/
|
|
20
20
|
|
21
21
|
### Forking Servers
|
22
22
|
|
23
|
-
If you want to run a worker pool in your web process and you're using a forking webserver like Unicorn or Puma in some configurations, you'll want to set `Que.mode = :off` in your application configuration and only start up the worker pool in the child processes after the DB connection has been reestablished. So, for Puma:
|
23
|
+
If you want to run a worker pool in your web process and you're using a forking webserver like Phusion Passenger (in smart spawning mode), Unicorn or Puma in some configurations, you'll want to set `Que.mode = :off` in your application configuration and only start up the worker pool in the child processes after the DB connection has been reestablished. So, for Puma:
|
24
24
|
|
25
25
|
# config/puma.rb
|
26
26
|
on_worker_boot do
|
@@ -38,6 +38,17 @@ And for Unicorn:
|
|
38
38
|
Que.mode = :async
|
39
39
|
end
|
40
40
|
|
41
|
+
And for Phusion Passenger:
|
42
|
+
|
43
|
+
# config.ru
|
44
|
+
if defined?(PhusionPassenger)
|
45
|
+
PhusionPassenger.on_event(:starting_worker_process) do |forked|
|
46
|
+
if forked
|
47
|
+
Que.mode = :async
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
41
52
|
|
42
53
|
### Managing the Jobs Table
|
43
54
|
|
@@ -8,18 +8,22 @@ module Que
|
|
8
8
|
def wake_worker_after_commit
|
9
9
|
# Works with ActiveRecord 3.2 and 4 (possibly earlier, didn't check)
|
10
10
|
if in_transaction?
|
11
|
-
checkout_activerecord_adapter { |adapter| adapter.add_transaction_record(
|
11
|
+
checkout_activerecord_adapter { |adapter| adapter.add_transaction_record(TransactionCallback.new) }
|
12
12
|
else
|
13
13
|
Que.wake!
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
class
|
17
|
+
class TransactionCallback
|
18
18
|
def has_transactional_callbacks?
|
19
19
|
true
|
20
20
|
end
|
21
21
|
|
22
|
-
def
|
22
|
+
def rolledback!(force_restore_state = false, should_run_callbacks = true)
|
23
|
+
# no-op
|
24
|
+
end
|
25
|
+
|
26
|
+
def committed!(should_run_callbacks = true)
|
23
27
|
Que.wake!
|
24
28
|
end
|
25
29
|
end
|
data/lib/que/job.rb
CHANGED
data/lib/que/version.rb
CHANGED
data/lib/que/worker.rb
CHANGED
@@ -151,18 +151,18 @@ module Que
|
|
151
151
|
end
|
152
152
|
|
153
153
|
def wake!
|
154
|
-
workers.find
|
154
|
+
workers.find(&:wake!)
|
155
155
|
end
|
156
156
|
|
157
157
|
def wake_all!
|
158
|
-
workers.each
|
158
|
+
workers.each(&:wake!)
|
159
159
|
end
|
160
160
|
|
161
161
|
private
|
162
162
|
|
163
163
|
def set_up_workers
|
164
164
|
if worker_count > workers.count
|
165
|
-
workers.push
|
165
|
+
workers.push(*(worker_count - workers.count).times.map{new(ENV['QUE_QUEUE'] || '')})
|
166
166
|
elsif worker_count < workers.count
|
167
167
|
workers.pop(workers.count - worker_count).each(&:stop).each(&:wait_until_stopped)
|
168
168
|
end
|
@@ -171,7 +171,7 @@ module Que
|
|
171
171
|
def wrangler
|
172
172
|
@wrangler ||= Thread.new do
|
173
173
|
loop do
|
174
|
-
sleep
|
174
|
+
sleep(*@wake_interval)
|
175
175
|
wake! if @wake_interval && mode == :async
|
176
176
|
end
|
177
177
|
end
|
data/lib/que.rb
CHANGED
@@ -4,7 +4,11 @@ unless defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
|
|
4
4
|
require 'spec_helper'
|
5
5
|
require 'active_record'
|
6
6
|
|
7
|
+
if ActiveRecord.version.release >= Gem::Version.new('4.2')
|
8
|
+
ActiveRecord::Base.raise_in_transactional_callbacks = true
|
9
|
+
end
|
7
10
|
ActiveRecord::Base.establish_connection(QUE_URL)
|
11
|
+
|
8
12
|
Que.connection = ActiveRecord
|
9
13
|
QUE_ADAPTERS[:active_record] = Que.adapter
|
10
14
|
|
@@ -101,6 +105,14 @@ unless defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
|
|
101
105
|
Que::Worker.workers.each { |worker| worker.should be_sleeping }
|
102
106
|
end
|
103
107
|
|
108
|
+
it "should be able to survive an ActiveRecord::Rollback without raising an error" do
|
109
|
+
ActiveRecord::Base.transaction do
|
110
|
+
Que::Job.enqueue
|
111
|
+
raise ActiveRecord::Rollback, "Call tech support!"
|
112
|
+
end
|
113
|
+
DB[:que_jobs].count.should be 0
|
114
|
+
end
|
115
|
+
|
104
116
|
it "should be able to tell when it's in an ActiveRecord transaction" do
|
105
117
|
Que.adapter.should_not be_in_transaction
|
106
118
|
ActiveRecord::Base.transaction do
|
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.8.
|
4
|
+
version: 0.8.2
|
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-10-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|