Strip default_ prefix from retry_jitter config to match conventions

上级 87397290
......@@ -8,8 +8,8 @@ module Exceptions
extend ActiveSupport::Concern
included do
class_attribute :default_retry_jitter, instance_accessor: false, instance_predicate: false
self.default_retry_jitter = 0.15
class_attribute :retry_jitter, instance_accessor: false, instance_predicate: false
self.retry_jitter = 0.15
end
module ClassMethods
......@@ -128,7 +128,7 @@ def retry_job(options = {})
private
def determine_delay(seconds_or_duration_or_algorithm:, executions:, jitter: nil)
jitter ||= self.class.default_retry_jitter
jitter ||= self.class.retry_jitter
case seconds_or_duration_or_algorithm
when :exponentially_longer
((executions**4) + (Kernel.rand((executions**4) * jitter))) + 2
......
......@@ -129,9 +129,9 @@ class ExceptionsTest < ActiveSupport::TestCase
end
end
test "retry jitter uses value from ActiveJob::Base.default_retry_jitter by default" do
old_jitter = ActiveJob::Base.default_retry_jitter
ActiveJob::Base.default_retry_jitter = 4.0
test "retry jitter uses value from ActiveJob::Base.retry_jitter by default" do
old_jitter = ActiveJob::Base.retry_jitter
ActiveJob::Base.retry_jitter = 4.0
travel_to Time.now
......@@ -151,7 +151,7 @@ class ExceptionsTest < ActiveSupport::TestCase
], JobBuffer.values
end
ensure
ActiveJob::Base.default_retry_jitter = old_jitter
ActiveJob::Base.retry_jitter = old_jitter
end
test "custom wait retrying job" do
......
......@@ -807,7 +807,7 @@ There are a few configuration options available in Active Support:
* `config.active_job.log_arguments` controls if the arguments of a job are logged. Defaults to `true`.
* `config.active_job.default_retry_jitter` controls the amount of "jitter" (random variation) applied to the delay time calculated when retrying failed jobs. Defaults to `0.15`.
* `config.active_job.retry_jitter` controls the amount of "jitter" (random variation) applied to the delay time calculated when retrying failed jobs. Defaults to `0.15`.
### Configuring Action Cable
......
......@@ -157,7 +157,7 @@ def load_defaults(target_version)
load_defaults "6.0"
if respond_to?(:active_job)
active_job.default_retry_jitter = 0.15
active_job.retry_jitter = 0.15
end
if respond_to?(:active_record)
......
......@@ -2262,18 +2262,18 @@ class ::DummySerializer < ActiveJob::Serializers::ObjectSerializer; end
end
end
test "ActiveJob::Base.default_retry_jitter is 0.15 by default" do
test "ActiveJob::Base.retry_jitter is 0.15 by default" do
app "development"
assert_equal 0.15, ActiveJob::Base.default_retry_jitter
assert_equal 0.15, ActiveJob::Base.retry_jitter
end
test "ActiveJob::Base.default_retry_jitter can be set by config" do
test "ActiveJob::Base.retry_jitter can be set by config" do
app "development"
Rails.application.config.active_job.default_retry_jitter = 0.22
Rails.application.config.active_job.retry_jitter = 0.22
assert_equal 0.22, ActiveJob::Base.default_retry_jitter
assert_equal 0.22, ActiveJob::Base.retry_jitter
end
test "ActiveJob::Base.return_false_on_aborted_enqueue is true by default" do
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册