Sha256: 1cfee0a55b4d6500287f9482943320deb5bd702090e0578a7de034cc4499c60f
Contents?: true
Size: 1.06 KB
Versions: 1
Compression:
Stored size: 1.06 KB
Contents
module SidekiqUniqueJobs module Unlockable module_function def unlock(item) unlock_by_key(item[UNIQUE_DIGEST_KEY], item[JID_KEY]) end def unlock_by_key(unique_key, jid, redis_pool = nil) result = Scripts.call(:release_lock, redis_pool, keys: [unique_key], argv: [jid]) after_unlock(result, __method__, unique_key, jid) end def after_unlock(result, calling_method, unique_key, jid) # rubocop:disable Metrics/MethodLength ensure_job_id_removed(jid) case result when 1 logger.debug { "successfully unlocked #{unique_key}" } true when 0 logger.debug { "expiring lock #{unique_key} is not owned by #{jid}" } false when -1 logger.debug { "#{unique_key} is not a known key" } false else raise "#{calling_method} returned an unexpected value (#{result})" end end def ensure_job_id_removed(jid) Sidekiq.redis { |redis| redis.hdel(SidekiqUniqueJobs::HASH_KEY, jid) } end def logger Sidekiq.logger end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sidekiq-unique-jobs-5.0.0 | lib/sidekiq_unique_jobs/unlockable.rb |