class ActiveJob::Uniqueness::Strategies::WhileExecuting
Locks the job when the job starts. Unlocks the job when the job is finished.
Public Instance Methods
around_perform(block)
click to toggle source
# File lib/active_job/uniqueness/strategies/while_executing.rb, line 16 def around_perform(block) return if @job_aborted # ActiveJob 4.2 workaround block.call ensure unlock(resource: lock_key, event: :runtime_unlock) unless @job_aborted end
before_perform()
click to toggle source
# File lib/active_job/uniqueness/strategies/while_executing.rb, line 9 def before_perform return if lock(resource: lock_key, ttl: lock_ttl, event: :runtime_lock) handle_conflict(resource: lock_key, event: :runtime_conflict, on_conflict: on_conflict) abort_job end