Class: Cloudtasker::UniqueJob::Lock::UntilExecuting
- Defined in:
- lib/cloudtasker/unique_job/lock/until_executing.rb
Overview
Conflict if any other job with the same args is scheduled while the first job is pending.
Instance Attribute Summary
Attributes inherited from BaseLock
Instance Method Summary collapse
-
#execute ⇒ Object
Release the lock and perform the job.
-
#schedule(&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
Constructor Details
This class inherits a constructor from Cloudtasker::UniqueJob::Lock::BaseLock
Instance Method Details
#execute ⇒ Object
Release the lock and perform the job.
23 24 25 26 |
# File 'lib/cloudtasker/unique_job/lock/until_executing.rb', line 23 def execute job.unlock! yield end |
#schedule(&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 |
# File 'lib/cloudtasker/unique_job/lock/until_executing.rb', line 13 def schedule(&block) job.lock! yield rescue LockError conflict_instance.on_schedule(&block) end |