Sha256: 15ec1e3f73fe5c26d640cd1c4d18f8a317e2b5563f699c1458cb50f1aeada87a

Contents?: true

Size: 823 Bytes

Versions: 6

Compression:

Stored size: 823 Bytes

Contents

# frozen_string_literal: true

module SidekiqUniqueJobs
  class Lock
    #
    # UntilExpired locks until the job expires
    #
    # @author Mikael Henriksson <mikael@mhenrixon.com>
    #
    class UntilExpired < UntilExecuted
      #
      # Locks a sidekiq job
      #
      # @note Will call a conflict strategy if lock can't be achieved.
      #
      # @return [String, nil] the locked jid when properly locked, else nil.
      #
      # @yield to the caller when given a block
      #
      def lock
        return lock_failed unless (job_id = locksmith.lock)
        return yield job_id if block_given?

        job_id
      end

      # Executes in the Sidekiq server process
      # @yield to the worker class perform method
      def execute(&block)
        locksmith.execute(&block)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
sidekiq-unique-jobs-7.1.6 lib/sidekiq_unique_jobs/lock/until_expired.rb
sidekiq-unique-jobs-7.1.5 lib/sidekiq_unique_jobs/lock/until_expired.rb
sidekiq-unique-jobs-7.1.3 lib/sidekiq_unique_jobs/lock/until_expired.rb
sidekiq-unique-jobs-7.1.2 lib/sidekiq_unique_jobs/lock/until_expired.rb
sidekiq-unique-jobs-7.1.1 lib/sidekiq_unique_jobs/lock/until_expired.rb
sidekiq-unique-jobs-7.1.0 lib/sidekiq_unique_jobs/lock/until_expired.rb