Class: Cloudtasker::UniqueJob::Lock::WhileExecuting
- Defined in:
- lib/cloudtasker/unique_job/lock/while_executing.rb
Overview
Conflict if any other job with the same args is moved to execution while the first job is executing.
Instance Attribute Summary
Attributes inherited from BaseLock
Instance Method Summary collapse
-
#execute(&block) ⇒ Object
Acquire a lock for the job and trigger a conflict if the lock could not be acquired.
Methods inherited from BaseLock
#conflict_instance, #default_conflict_strategy, #initialize, #options, #schedule
Constructor Details
This class inherits a constructor from Cloudtasker::UniqueJob::Lock::BaseLock
Instance Method Details
#execute(&block) ⇒ Object
Acquire a lock for the job and trigger a conflict if the lock could not be acquired.
13 14 15 16 17 18 19 20 21 |
# File 'lib/cloudtasker/unique_job/lock/while_executing.rb', line 13 def execute(&block) job.lock! yield rescue LockError conflict_instance.on_execute(&block) ensure # Unlock the job on any error to avoid deadlocks. job.unlock! end |