Sha256: e21a82946ff736cd843e6cbb18828c7413f864e6c7cbbc8d04ab3525973f43c3

Contents?: true

Size: 632 Bytes

Versions: 49

Compression:

Stored size: 632 Bytes

Contents

# frozen_string_literal: true

module Cloudtasker
  module UniqueJob
    module Lock
      # Conflict if any other job with the same args is moved to execution
      # while the first job is executing.
      class WhileExecuting < BaseLock
        #
        # 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

Version Path
cloudtasker-0.13.2 lib/cloudtasker/unique_job/lock/while_executing.rb
cloudtasker-0.13.1 lib/cloudtasker/unique_job/lock/while_executing.rb
cloudtasker-0.13.0 lib/cloudtasker/unique_job/lock/while_executing.rb
cloudtasker-0.13.rc2 lib/cloudtasker/unique_job/lock/while_executing.rb
cloudtasker-0.13.rc1 lib/cloudtasker/unique_job/lock/while_executing.rb
cloudtasker-0.12.2 lib/cloudtasker/unique_job/lock/while_executing.rb
cloudtasker-0.12.1 lib/cloudtasker/unique_job/lock/while_executing.rb
cloudtasker-0.11.1 lib/cloudtasker/unique_job/lock/while_executing.rb
cloudtasker-0.10.2 lib/cloudtasker/unique_job/lock/while_executing.rb
cloudtasker-0.9.5 lib/cloudtasker/unique_job/lock/while_executing.rb
cloudtasker-0.12.0 lib/cloudtasker/unique_job/lock/while_executing.rb
cloudtasker-0.12.rc11 lib/cloudtasker/unique_job/lock/while_executing.rb
cloudtasker-0.12.rc10 lib/cloudtasker/unique_job/lock/while_executing.rb
cloudtasker-0.12.rc9 lib/cloudtasker/unique_job/lock/while_executing.rb
cloudtasker-0.12.rc8 lib/cloudtasker/unique_job/lock/while_executing.rb
cloudtasker-0.12.rc7 lib/cloudtasker/unique_job/lock/while_executing.rb
cloudtasker-0.12.rc6 lib/cloudtasker/unique_job/lock/while_executing.rb
cloudtasker-0.12.rc5 lib/cloudtasker/unique_job/lock/while_executing.rb
cloudtasker-0.12.rc4 lib/cloudtasker/unique_job/lock/while_executing.rb
cloudtasker-0.12.rc3 lib/cloudtasker/unique_job/lock/while_executing.rb