Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Backpedal from class-oriented config.queue. Set an actual queue insta…

…nce.
  • Loading branch information...
commit c8fe0d58bcc7deb49711606566c854bf0ed7f107 1 parent 1dc2ea8
@jeremy jeremy authored
View
4 activesupport/lib/active_support/queueing.rb
@@ -64,10 +64,6 @@ def push(job)
# queue and joins the thread, which will ensure that all jobs
# are executed before the process finally dies.
class ThreadedQueueConsumer
- def self.start(*args)
- new(*args).start
- end
-
def initialize(queue, options = {})
@queue = queue
@logger = options[:logger]
View
4 guides/source/4_0_release_notes.md
@@ -95,9 +95,9 @@ Railties
* Load all environments available in `config.paths["config/environments"]`.
-* Add `config.queue_consumer` to allow the default consumer to be configurable.
+* Add `config.queue_consumer` to change the job queue consumer from the default `ActiveSupport::ThreadedQueueConsumer`.
-* Add `Rails.queue` as an interface with a default implementation that consumes jobs in a separate thread.
+* Add `Rails.queue` for processing jobs in the background.
* Remove `Rack::SSL` in favour of `ActionDispatch::SSL`.
View
4 guides/source/configuring.md
@@ -115,9 +115,9 @@ NOTE. The `config.asset_path` configuration is ignored if the asset pipeline is
* `config.middleware` allows you to configure the application's middleware. This is covered in depth in the [Configuring Middleware](#configuring-middleware) section below.
-* `config.queue` configures a different queue implementation for the application. Defaults to `ActiveSupport::SynchronousQueue`. Note that, if the default queue is changed, the default `queue_consumer` is not going to be initialized, it is up to the new queue implementation to handle starting and shutting down its own consumer(s).
+* `config.queue` configures the default job queue for the application. Defaults to `ActiveSupport::Queue.new` which processes jobs in a background thread. If you change the queue, you're responsible for running the jobs as well.
-* `config.queue_consumer` configures a different consumer implementation for the default queue. Defaults to `ActiveSupport::ThreadedQueueConsumer`.
+* `config.queue_consumer` configures a different job consumer for the default queue. Defaults to `ActiveSupport::ThreadedQueueConsumer`. The job consumer must respond to `start`.
* `config.reload_classes_only_on_change` enables or disables reloading of classes only when tracked files change. By default tracks everything on autoload paths and is set to true. If `config.cache_classes` is true, this option is ignored.
View
4 railties/CHANGELOG.md
@@ -81,9 +81,9 @@
* Load all environments available in `config.paths["config/environments"]`. *Piotr Sarnacki*
-* Add `config.queue_consumer` to allow the default consumer to be configurable. *Carlos Antonio da Silva*
+* Add `config.queue_consumer` to change the job queue consumer from the default `ActiveSupport::ThreadedQueueConsumer`. *Carlos Antonio da Silva*
-* Add Rails.queue as an interface with a default implementation that consumes jobs in a separate thread. *Yehuda Katz*
+* Add `Rails.queue` for processing jobs in the background. *Yehuda Katz*
* Remove Rack::SSL in favour of ActionDispatch::SSL. *Rafael Mendonça França*
View
2  railties/lib/rails/application/configuration.rb
@@ -43,7 +43,7 @@ def initialize(*)
@exceptions_app = nil
@autoflush_log = true
@log_formatter = ActiveSupport::Logger::SimpleFormatter.new
- @queue = ActiveSupport::SynchronousQueue
+ @queue = ActiveSupport::SynchronousQueue.new
@queue_consumer = ActiveSupport::ThreadedQueueConsumer
@eager_load = nil
View
4 railties/lib/rails/application/finisher.rb
@@ -97,8 +97,8 @@ module Finisher
end
initializer :activate_queue_consumer do |app|
- if config.queue == ActiveSupport::Queue
- app.queue_consumer = config.queue_consumer.start(app.queue, {logger: Rails.logger})
+ if config.queue.class == ActiveSupport::Queue
+ app.queue_consumer = config.queue_consumer.start
at_exit { app.queue_consumer.shutdown }
end
end
View
2  railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt
@@ -88,5 +88,5 @@
# Default the production mode queue to an synchronous queue. You will probably
# want to replace this with an out-of-process queueing solution.
- # config.queue = ActiveSupport::SynchronousQueue
+ # config.queue = ActiveSupport::SynchronousQueue.new
end
View
2  railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt
@@ -35,5 +35,5 @@
config.active_support.deprecation = :stderr
# Use the synchronous queue to run jobs immediately.
- config.queue = ActiveSupport::SynchronousQueue
+ config.queue = ActiveSupport::SynchronousQueue.new
end
View
8 railties/test/application/configuration_test.rb
@@ -56,14 +56,6 @@ def teardown
assert_match "ActiveRecord::PendingMigrationError", last_response.body
end
- test "multiple queue construction is possible" do
- require 'rails'
- require "#{app_path}/config/environment"
- mail_queue = Rails.application.build_queue
- image_processing_queue = Rails.application.build_queue
- assert_not_equal mail_queue, image_processing_queue
- end
-
test "Rails.groups returns available groups" do
require "rails"
View
6 railties/test/application/queue_test.rb
@@ -113,12 +113,12 @@ def run
test "a custom consumer implementation can be provided" do
add_to_env_config "production", <<-RUBY
require "my_queue_consumer"
- config.queue = ActiveSupport::Queue
- config.queue_consumer = MyQueueConsumer
+ config.queue = ActiveSupport::Queue.new
+ config.queue_consumer = MyQueueConsumer.new
RUBY
app_file "lib/my_queue_consumer.rb", <<-RUBY
- class MyQueueConsumer < ActiveSupport::ThreadedQueueConsumer
+ class MyQueueConsumer
attr_reader :started
def start
Please sign in to comment.
Something went wrong with that request. Please try again.