que 0.8.1 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5c7ef330bef62b6f1407608630ada0a4522e3d36
4
- data.tar.gz: d7e98fbbc652b8299c21be083a464ab263bbdf40
3
+ metadata.gz: 8029277244c5b5f8e4d838c9e16b2ebddd402919
4
+ data.tar.gz: 06fe39d7feb085098468d4b7f019aa0a40433016
5
5
  SHA512:
6
- metadata.gz: a85590d23bc40818ba9bbe1fdd37cecb10d580f864b841aa1382be3ee9bbb200d7732379c0c604e61d6bfbb9384599a6f5e24f1123ef6acd00ca659a8ca67c1b
7
- data.tar.gz: 30967fd239d28158742e143520c23e1f00e061bf709157efd7b1654e3ba4bbc2d8a9af475127aa63e865b9772365ac1b3ea056a6b52414607e2115fb0b944871
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)
@@ -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(CommittedCallback.new) }
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 CommittedCallback
17
+ class TransactionCallback
18
18
  def has_transactional_callbacks?
19
19
  true
20
20
  end
21
21
 
22
- def committed!
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
@@ -12,7 +12,7 @@ module Que
12
12
  end
13
13
 
14
14
  def _run
15
- run *attrs[:args]
15
+ run(*attrs[:args])
16
16
  destroy unless @destroyed
17
17
  end
18
18
 
data/lib/que/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Que
2
- Version = '0.8.1'
2
+ Version = '0.8.2'
3
3
  end
data/lib/que/worker.rb CHANGED
@@ -151,18 +151,18 @@ module Que
151
151
  end
152
152
 
153
153
  def wake!
154
- workers.find &:wake!
154
+ workers.find(&:wake!)
155
155
  end
156
156
 
157
157
  def wake_all!
158
- workers.each &:wake!
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 *(worker_count - workers.count).times.map{new(ENV['QUE_QUEUE'] || '')}
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 *@wake_interval
174
+ sleep(*@wake_interval)
175
175
  wake! if @wake_interval && mode == :async
176
176
  end
177
177
  end
data/lib/que.rb CHANGED
@@ -32,8 +32,8 @@ module Que
32
32
  when 'Pond' then Adapters::Pond.new(connection)
33
33
  when 'NilClass' then connection
34
34
  else raise "Que connection not recognized: #{connection.inspect}"
35
+ end
35
36
  end
36
- end
37
37
  end
38
38
 
39
39
  def adapter
@@ -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.1
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-07-29 00:00:00.000000000 Z
11
+ date: 2014-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler