-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(unique-jobs): Fix on retry in unique jobs (#2862)
## Context `retry_on` does not work with `until_executed` strategy. veeqo/activejob-uniqueness#75 ## Description This PR updates all the jobs that are affected with this issue - a combination of `retry_on` and `unique :until_executed`
- Loading branch information
1 parent
8435425
commit 6d38b79
Showing
8 changed files
with
29 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
lib/active_job/uniqueness/strategies/until_executed_patch.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# frozen_string_literal: true | ||
|
||
require "active_job/uniqueness/strategies/until_executed" | ||
|
||
# https://github.com/veeqo/activejob-uniqueness/issues/75 | ||
# retry_on does not work with until_executed strategy | ||
|
||
module ActiveJob | ||
module Uniqueness | ||
module Strategies | ||
module UntilExecutedPatch | ||
def before_enqueue | ||
return if lock(resource: lock_key, ttl: lock_ttl) | ||
# We're retrying the job, so we don't need to lock again | ||
return if job.executions > 0 | ||
|
||
handle_conflict(resource: lock_key, on_conflict: on_conflict) | ||
abort_job | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
||
ActiveJob::Uniqueness::Strategies::UntilExecuted.prepend( | ||
ActiveJob::Uniqueness::Strategies::UntilExecutedPatch | ||
) |