Sha256: 6b1fb2026dc598ef4f1cf149f105dca2ad407ad9ba643ba773b8ea740fede96d
Contents?: true
Size: 925 Bytes
Versions: 49
Compression:
Stored size: 925 Bytes
Contents
# frozen_string_literal: true module Cloudtasker module UniqueJob module Lock # Conflict if any other job with the same args is scheduled or moved to execution # while the first job is pending or executing. class UntilExecuted < BaseLock # # Acquire a lock for the job and trigger a conflict # if the lock could not be acquired. # def schedule job.lock! yield rescue LockError conflict_instance.on_schedule { yield } end # # Acquire a lock for the job and trigger a conflict # if the lock could not be acquired. # 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 end end end end
Version data entries
49 entries across 49 versions & 1 rubygems