1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Send Active Storage jobs to dedicated queues by default

Match Action Mailbox, which sets a default queue for each of its two jobs.
This commit is contained in:
George Claghorn 2019-01-04 12:43:51 -05:00 committed by GitHub
parent a86b64918b
commit 663f6cc14f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 49 additions and 2 deletions

View file

@ -906,6 +906,8 @@ text/javascript image/svg+xml application/postscript application/x-shockwave-fla
- `config.action_view.default_enforce_utf8`: `false`
- `config.action_dispatch.use_cookies_with_metadata`: `true`
- `config.active_job.return_false_on_aborted_enqueue`: `true`
- `config.active_storage.queues.analysis`: `:active_storage_analysis`
- `config.active_storage.queues.purge`: `:active_storage_purge`
### Configuring a Database

View file

@ -1,3 +1,11 @@
* Send Active Storage analysis and purge jobs to dedicated queues by default.
Analysis jobs now use the `:active_storage_analysis` queue, and purge jobs
now use the `:active_storage_purge` queue. This matches Action Mailbox,
which sends its jobs to dedicated queues by default.
*George Claghorn*
* Add `rails test:mailboxes`.
*George Claghorn*

View file

@ -133,6 +133,11 @@ module Rails
if respond_to?(:active_job)
active_job.return_false_on_aborted_enqueue = true
end
if respond_to?(:active_storage)
active_storage.queues.analysis = :active_storage_analysis
active_storage.queues.purge = :active_storage_purge
end
else
raise "Unknown version #{target_version.to_s.inspect}"
end

View file

@ -6,7 +6,7 @@
#
# Read the Guide for Upgrading Ruby on Rails for more info on each option.
# Don't force requests from old versions of IE to be UTF-8 encoded
# Don't force requests from old versions of IE to be UTF-8 encoded.
# Rails.application.config.action_view.default_enforce_utf8 = false
# Embed purpose and expiry metadata inside signed and encrypted
@ -16,5 +16,9 @@
# It's best enabled when your entire app is migrated and stable on 6.0.
# Rails.application.config.action_dispatch.use_cookies_with_metadata = true
# Return false instead of self when #enqueue method was aborted from the callback
# Return false instead of self when enqueuing is aborted from a callback.
Rails.application.config.active_job.return_false_on_aborted_enqueue = true
# Send Active Storage analysis and purge jobs to dedicated queues.
# Rails.application.config.active_storage.queues.analysis = :active_storage_analysis
# Rails.application.config.active_storage.queues.purge = :active_storage_purge

View file

@ -2226,6 +2226,34 @@ module ApplicationTests
assert_equal true, ActiveJob::Base.return_false_on_aborted_enqueue
end
test "ActiveStorage.queues[:analysis] is :active_storage_analysis by default" do
app "development"
assert_equal :active_storage_analysis, ActiveStorage.queues[:analysis]
end
test "ActiveStorage.queues[:analysis] is nil without Rails 6 defaults" do
remove_from_config '.*config\.load_defaults.*\n'
app "development"
assert_nil ActiveStorage.queues[:analysis]
end
test "ActiveStorage.queues[:purge] is :active_storage_purge by default" do
app "development"
assert_equal :active_storage_purge, ActiveStorage.queues[:purge]
end
test "ActiveStorage.queues[:purge] is nil without Rails 6 defaults" do
remove_from_config '.*config\.load_defaults.*\n'
app "development"
assert_nil ActiveStorage.queues[:purge]
end
test "ActiveRecord::Base.filter_attributes should equal to filter_parameters" do
app_file "config/initializers/filter_parameters_logging.rb", <<-RUBY
Rails.application.config.filter_parameters += [ :password, :credit_card_number ]