Sha256: de506421257343a809e5ee81c64bba87a771401b339c4dd258aacdfed06c895d

Contents?: true

Size: 762 Bytes

Versions: 4

Compression:

Stored size: 762 Bytes

Contents

module SidekiqUniqueJobs
  module Unlockable
    module_function

    # rubocop:disable MethodLength
    def unlock(unique_key, jid, redis_pool = nil)
      result = Scripts.call(:release_lock, redis_pool,
                            keys: [unique_key],
                            argv: [jid])
      case result
      when 1
        Sidekiq.logger.debug { "successfully unlocked #{unique_key}" }
        true
      when 0
        Sidekiq.logger.debug { "expiring lock #{unique_key} is not owned by #{jid}" }
        false
      when -1
        Sidekiq.logger.debug { "#{unique_key} is not a known key" }
        false
      else
        fail "#{__method__} returned an unexpected value (#{result})"
      end
    end
    # rubocop:enable MethodLength
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sidekiq-unique-jobs-4.0.9 lib/sidekiq_unique_jobs/unlockable.rb
sidekiq-unique-jobs-4.0.8 lib/sidekiq_unique_jobs/unlockable.rb
sidekiq-unique-jobs-4.0.7 lib/sidekiq_unique_jobs/unlockable.rb
sidekiq-unique-jobs-4.0.0 lib/sidekiq_unique_jobs/unlockable.rb