Skip to content

Commit

Permalink
Change default queue name of all the internal jobs to be the job adap…
Browse files Browse the repository at this point in the history
…ter's default

`config.active_storage.queues.analysis`:
From `:active_storage_analysis` to `nil`.

`config.active_storage.queues.purge`:
From `:active_storage_purge` to `nil`.

`config.action_mailbox.queues.incineration`:
From `:action_mailbox_incineration` to `nil`.

`config.action_mailbox.queues.routing`:
From `:action_mailbox_routing` to `nil`.

`config.action_mailer.deliver_later_queue_name`:
From `:mailers` to `nil`.

Fixes rails#40730.
  • Loading branch information
rafaelfranca committed Dec 8, 2020
1 parent 49931cc commit 3930449
Show file tree
Hide file tree
Showing 9 changed files with 149 additions and 12 deletions.
6 changes: 6 additions & 0 deletions actionmailbox/CHANGELOG.md
@@ -1,3 +1,9 @@
* Change default queue name of the incineration (`:action_mailbox_incineration`) and
routing (`:action_mailbox_routing`) jobs to be the job adapter's default (`:default`).

*Rafael Mendonça França*


## Rails 6.1.0.rc2 (December 01, 2020) ##

* No changes.
Expand Down
6 changes: 6 additions & 0 deletions actionmailer/CHANGELOG.md
@@ -1,3 +1,9 @@
* Change default queue name of the deliver (`:mailers`) job to be the job adapter's
default (`:default`).

*Rafael Mendonça França*


## Rails 6.1.0.rc2 (December 01, 2020) ##

* No changes.
Expand Down
2 changes: 1 addition & 1 deletion activerecord/lib/active_record/railtie.rb
Expand Up @@ -31,7 +31,7 @@ class Railtie < Rails::Railtie # :nodoc:
config.active_record.maintain_test_schema = true
config.active_record.has_many_inversing = false

config.active_record.queues = ActiveSupport::InheritableOptions.new(destroy: :active_record_destroy)
config.active_record.queues = ActiveSupport::InheritableOptions.new

config.eager_load_namespaces << ActiveRecord

Expand Down
6 changes: 6 additions & 0 deletions activestorage/CHANGELOG.md
@@ -1,3 +1,9 @@
* Change default queue name of the analysis (`:active_storage_analysis`) and
purge (`:active_storage_purge`) jobs to be the job adapter's default (`:default`).

*Rafael Mendonça França*


## Rails 6.1.0.rc2 (December 01, 2020) ##

* Implement `strict_loading` on ActiveStorage associations.
Expand Down
2 changes: 1 addition & 1 deletion activestorage/lib/active_storage/engine.rb
Expand Up @@ -26,7 +26,7 @@ class Engine < Rails::Engine # :nodoc:
config.active_storage.previewers = [ ActiveStorage::Previewer::PopplerPDFPreviewer, ActiveStorage::Previewer::MuPDFPreviewer, ActiveStorage::Previewer::VideoPreviewer ]
config.active_storage.analyzers = [ ActiveStorage::Analyzer::ImageAnalyzer, ActiveStorage::Analyzer::VideoAnalyzer ]
config.active_storage.paths = ActiveSupport::OrderedOptions.new
config.active_storage.queues = ActiveSupport::InheritableOptions.new(mirror: :active_storage_mirror)
config.active_storage.queues = ActiveSupport::InheritableOptions.new

config.active_storage.variable_content_types = %w(
image/png
Expand Down
17 changes: 11 additions & 6 deletions guides/source/configuring.md
Expand Up @@ -473,7 +473,7 @@ in controllers and views. This defaults to `false`.

* `config.active_record.destroy_association_async_job` allows specifying the job that will be used to destroy the associated records in background. It defaults to `ActiveRecord::DestroyAssociationAsyncJob`.

* `config.active_record.queues.destroy` allows specifying the Active Job queue to use for destroy jobs. It defaults to `:active_record_destroy`.
* `config.active_record.queues.destroy` allows specifying the Active Job queue to use for destroy jobs. When this option is `nil`, purge jobs are sent to the default Active Job queue (see `config.active_job.default_queue_name`). It defaults to `nil`.

The MySQL adapter adds one additional configuration option:

Expand Down Expand Up @@ -725,9 +725,9 @@ Defaults to `'signed cookie'`.
config.action_mailbox.incinerate_after = 14.days
```

* `config.action_mailbox.queues.incineration` accepts a symbol indicating the Active Job queue to use for incineration jobs. It defaults to `:action_mailbox_incineration`.
* `config.action_mailbox.queues.incineration` accepts a symbol indicating the Active Job queue to use for incineration jobs. When this option is `nil`, purge jobs are sent to the default Active Job queue (see `config.active_job.default_queue_name`). It defaults to `:action_mailbox_incineration`.

* `config.action_mailbox.queues.routing` accepts a symbol indicating the Active Job queue to use for routing jobs. It defaults to `:action_mailbox_routing`.
* `config.action_mailbox.queues.routing` accepts a symbol indicating the Active Job queue to use for routing jobs. When this option is `nil`, purge jobs are sent to the default Active Job queue (see `config.active_job.default_queue_name`). It defaults to `:action_mailbox_routing`.


### Configuring Action Mailer
Expand Down Expand Up @@ -956,19 +956,19 @@ text/javascript image/svg+xml application/postscript application/x-shockwave-fla

* `config.active_storage.content_types_allowed_inline` accepts an array of strings indicating the content types that Active Storage allows to serve as inline. The default is `%w(image/png image/gif image/jpg image/jpeg image/tiff image/bmp image/vnd.adobe.photoshop image/vnd.microsoft.icon application/pdf)`.

* `config.active_storage.queues.analysis` accepts a symbol indicating the Active Job queue to use for analysis jobs. When this option is `nil`, analysis jobs are sent to the default Active Job queue (see `config.active_job.default_queue_name`).
* `config.active_storage.queues.analysis` accepts a symbol indicating the Active Job queue to use for analysis jobs. When this option is `nil`, analysis jobs are sent to the default Active Job queue (see `config.active_job.default_queue_name`). The default is `nil`.

```ruby
config.active_storage.queues.analysis = :low_priority
```

* `config.active_storage.queues.purge` accepts a symbol indicating the Active Job queue to use for purge jobs. When this option is `nil`, purge jobs are sent to the default Active Job queue (see `config.active_job.default_queue_name`).
* `config.active_storage.queues.purge` accepts a symbol indicating the Active Job queue to use for purge jobs. When this option is `nil`, purge jobs are sent to the default Active Job queue (see `config.active_job.default_queue_name`). The default is `nil`.

```ruby
config.active_storage.queues.purge = :low_priority
```

* `config.active_storage.queues.mirror` accepts a symbol indicating the Active Job queue to use for direct upload mirroring jobs. The default is `:active_storage_mirror`.
* `config.active_storage.queues.mirror` accepts a symbol indicating the Active Job queue to use for direct upload mirroring jobs. When this option is `nil`, purge jobs are sent to the default Active Job queue (see `config.active_job.default_queue_name`). The default is `nil`.

```ruby
config.active_storage.queues.mirror = :low_priority
Expand Down Expand Up @@ -1018,6 +1018,11 @@ text/javascript image/svg+xml application/postscript application/x-shockwave-fla
- `config.active_record.has_many_inversing`: `true`
- `config.active_record.legacy_connection_handling`: `false`
- `config.active_storage.track_variants`: `true`
- `config.active_storage.queues.analysis`: `nil`
- `config.active_storage.queues.purge`: `nil`
- `config.action_mailbox.queues.incineration`: `nil`
- `config.action_mailbox.queues.routing`: `nil`
- `config.action_mailer.deliver_later_queue_name`: `nil`
- `config.active_job.retry_jitter`: `0.15`
- `config.active_job.skip_after_callbacks_if_terminated`: `true`
- `config.action_dispatch.cookies_same_site_protection`: `:lax`
Expand Down
14 changes: 14 additions & 0 deletions railties/lib/rails/application/configuration.rb
Expand Up @@ -185,6 +185,20 @@ def load_defaults(target_version)
action_view.form_with_generates_remote_forms = false
end

if respond_to?(:active_storage)
active_storage.queues.analysis = nil
active_storage.queues.purge = nil
end

if respond_to?(:action_mailbox)
action_mailbox.queues.incineration = nil
action_mailbox.queues.routing = nil
end

if respond_to?(:action_mailer)
action_mailer.deliver_later_queue_name = nil
end

ActiveSupport.utc_to_local_returns_utc_offset_times = true
else
raise "Unknown version #{target_version.to_s.inspect}"
Expand Down
Expand Up @@ -46,3 +46,18 @@

# Make `form_with` generate non-remote forms by default.
# Rails.application.config.action_view.form_with_generates_remote_forms = false

# Set the default queue name for the analysis job to the queue adapter default.
# Rails.application.config.active_storage.queues.analysis = nil

# Set the default queue name for the purge job to the queue adapter default.
# Rails.application.config.active_storage.queues.purge = nil

# Set the default queue name for the incineration job to the queue adapter default.
# Rails.application.config.action_mailbox.queues.incineration = nil

# Set the default queue name for the routing job to the queue adapter default.
# Rails.application.config.action_mailbox.queues.routing = nil

# Set the default queue name for the mail deliver job to the queue adapter default.
# Rails.application.config.action_mailer.deliver_later_queue_name = nil
93 changes: 89 additions & 4 deletions railties/test/application/configuration_test.rb
Expand Up @@ -1149,6 +1149,29 @@ def index
assert_equal "test_default", ActionMailer::Base.class_variable_get(:@@deliver_later_queue_name)
end

test "ActionMailer::DeliveryJob queue name is :mailers without the Rails defaults" do
remove_from_config '.*config\.load_defaults.*\n'

app "development"

require "mail"
_ = ActionMailer::Base

assert_equal :mailers, ActionMailer::Base.class_variable_get(:@@deliver_later_queue_name)
end

test "ActionMailer::DeliveryJob queue name is nil by default in 6.1" do
remove_from_config '.*config\.load_defaults.*\n'
add_to_config 'config.load_defaults "6.1"'

app "development"

require "mail"
_ = ActionMailer::Base

assert_nil ActionMailer::Base.class_variable_get(:@@deliver_later_queue_name)
end

test "valid timezone is setup correctly" do
add_to_config <<-RUBY
config.root = "#{app_path}"
Expand Down Expand Up @@ -2438,12 +2461,24 @@ class ::DummySerializer < ActiveJob::Serializers::ObjectSerializer; end
assert_equal true, ActiveSupport.utc_to_local_returns_utc_offset_times
end

test "ActiveStorage.queues[:analysis] is :active_storage_analysis by default" do
test "ActiveStorage.queues[:analysis] is :active_storage_analysis by default in 6.0" do
remove_from_config '.*config\.load_defaults.*\n'
add_to_config 'config.load_defaults "6.0"'

app "development"

assert_equal :active_storage_analysis, ActiveStorage.queues[:analysis]
end

test "ActiveStorage.queues[:analysis] is nil by default in 6.1" do
remove_from_config '.*config\.load_defaults.*\n'
add_to_config 'config.load_defaults "6.1"'

app "development"

assert_nil ActiveStorage.queues[:analysis]
end

test "ActiveStorage.queues[:analysis] is nil without Rails 6 defaults" do
remove_from_config '.*config\.load_defaults.*\n'

Expand All @@ -2452,12 +2487,24 @@ class ::DummySerializer < ActiveJob::Serializers::ObjectSerializer; end
assert_nil ActiveStorage.queues[:analysis]
end

test "ActiveStorage.queues[:purge] is :active_storage_purge by default" do
test "ActiveStorage.queues[:purge] is :active_storage_purge by default in 6.0" do
remove_from_config '.*config\.load_defaults.*\n'
add_to_config 'config.load_defaults "6.0"'

app "development"

assert_equal :active_storage_purge, ActiveStorage.queues[:purge]
end

test "ActiveStorage.queues[:purge] is nil by default in 6.1" do
remove_from_config '.*config\.load_defaults.*\n'
add_to_config 'config.load_defaults "6.1"'

app "development"

assert_nil ActiveStorage.queues[:purge]
end

test "ActiveStorage.queues[:purge] is nil without Rails 6 defaults" do
remove_from_config '.*config\.load_defaults.*\n'

Expand All @@ -2466,6 +2513,20 @@ class ::DummySerializer < ActiveJob::Serializers::ObjectSerializer; end
assert_nil ActiveStorage.queues[:purge]
end

test "ActiveStorage.queues[:mirror] is nil without Rails 6 defaults" do
remove_from_config '.*config\.load_defaults.*\n'

app "development"

assert_nil ActiveStorage.queues[:mirror]
end

test "ActiveStorage.queues[:mirror] is nil by default" do
app "development"

assert_nil ActiveStorage.queues[:mirror]
end

test "ActionCable.server.config.cable is set when missing configuration for the current environment" do
quietly do
app "missing"
Expand Down Expand Up @@ -2513,12 +2574,24 @@ class MyLogger < ::Logger
assert_equal 14.days, ActionMailbox.incinerate_after
end

test "ActionMailbox.queues[:incineration] is :action_mailbox_incineration by default" do
test "ActionMailbox.queues[:incineration] is :action_mailbox_incineration by default in 6.0" do
remove_from_config '.*config\.load_defaults.*\n'
add_to_config 'config.load_defaults "6.0"'

app "development"

assert_equal :action_mailbox_incineration, ActionMailbox.queues[:incineration]
end

test "ActionMailbox.queues[:incineration] is nil by default in 6.1" do
remove_from_config '.*config\.load_defaults.*\n'
add_to_config 'config.load_defaults "6.1"'

app "development"

assert_nil ActionMailbox.queues[:incineration]
end

test "ActionMailbox.queues[:incineration] can be configured" do
add_to_config <<-RUBY
config.action_mailbox.queues.incineration = :another_queue
Expand All @@ -2529,12 +2602,24 @@ class MyLogger < ::Logger
assert_equal :another_queue, ActionMailbox.queues[:incineration]
end

test "ActionMailbox.queues[:routing] is :action_mailbox_routing by default" do
test "ActionMailbox.queues[:routing] is :action_mailbox_routing by default in 6.0" do
remove_from_config '.*config\.load_defaults.*\n'
add_to_config 'config.load_defaults "6.0"'

app "development"

assert_equal :action_mailbox_routing, ActionMailbox.queues[:routing]
end

test "ActionMailbox.queues[:routing] is nil by default in 6.1" do
remove_from_config '.*config\.load_defaults.*\n'
add_to_config 'config.load_defaults "6.1"'

app "development"

assert_nil ActionMailbox.queues[:routing]
end

test "ActionMailbox.queues[:routing] can be configured" do
add_to_config <<-RUBY
config.action_mailbox.queues.routing = :another_queue
Expand Down

0 comments on commit 3930449

Please sign in to comment.