Class: Cloudtasker::UniqueJob::Lock::UntilExecuted
- Defined in:
- lib/cloudtasker/unique_job/lock/until_executed.rb
Overview
Conflict if any other job with the same args is scheduled or moved to execution while the first job is pending or executing.
Instance Attribute Summary
Attributes inherited from BaseLock
Instance Method Summary collapse
-
#execute ⇒ Object
Acquire a lock for the job and trigger a conflict if the lock could not be acquired.
-
#schedule ⇒ 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
Constructor Details
This class inherits a constructor from Cloudtasker::UniqueJob::Lock::BaseLock
Instance Method Details
#execute ⇒ Object
Acquire a lock for the job and trigger a conflict if the lock could not be acquired.
24 25 26 27 28 29 30 31 32 |
# File 'lib/cloudtasker/unique_job/lock/until_executed.rb', line 24 def execute job.lock! yield rescue LockError conflict_instance.on_execute { yield } ensure # Unlock the job on any error to avoid deadlocks. job.unlock! end |
#schedule ⇒ Object
Acquire a lock for the job and trigger a conflict if the lock could not be acquired.
13 14 15 16 17 18 |
# File 'lib/cloudtasker/unique_job/lock/until_executed.rb', line 13 def schedule job.lock! yield rescue LockError conflict_instance.on_schedule { yield } end |