Skip to content

Commit

Permalink
Address rails 7.1 deprecations when using Concurrency (#1097)
Browse files Browse the repository at this point in the history
  • Loading branch information
Earlopain committed Oct 4, 2023
1 parent c5573c7 commit 77a6262
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ GoodJob.on_thread_error = -> (exception) { Rails.error.report(exception) }
By default, GoodJob relies on ActiveJob's retry functionality.
ActiveJob can be configured to retry an infinite number of times, with an exponential backoff. Using ActiveJob's `retry_on` prevents exceptions from reaching GoodJob:
ActiveJob can be configured to retry an infinite number of times, with a polynomial backoff. Using ActiveJob's `retry_on` prevents exceptions from reaching GoodJob:
```ruby
class ApplicationJob < ActiveJob::Base
Expand Down
8 changes: 7 additions & 1 deletion lib/good_job/active_job_extensions/concurrency.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,16 @@ def deserialize(job_data)
end
end

wait_key = if ActiveJob.gem_version >= Gem::Version.new("7.1.0")
:polynomially_longer
else
:exponentially_longer
end

retry_on(
GoodJob::ActiveJobExtensions::Concurrency::ConcurrencyExceededError,
attempts: Float::INFINITY,
wait: :exponentially_longer
wait: wait_key
)

before_perform do |job|
Expand Down

0 comments on commit 77a6262

Please sign in to comment.