Module: SidekiqUniqueJobs::Unlockable
- Included in:
- Lock::UntilExecuted
- Defined in:
- lib/sidekiq_unique_jobs/unlockable.rb
Class Method Summary collapse
-
.after_unlock(result, calling_method, unique_key, jid) ⇒ Object
rubocop:disable Metrics/MethodLength.
- .ensure_job_id_removed(jid) ⇒ Object
- .logger ⇒ Object
- .unlock(item) ⇒ Object
- .unlock_by_key(unique_key, jid, redis_pool = nil) ⇒ Object
Class Method Details
.after_unlock(result, calling_method, unique_key, jid) ⇒ Object
rubocop:disable Metrics/MethodLength
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/sidekiq_unique_jobs/unlockable.rb', line 14 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 |
.ensure_job_id_removed(jid) ⇒ Object
32 33 34 |
# File 'lib/sidekiq_unique_jobs/unlockable.rb', line 32 def ensure_job_id_removed(jid) Sidekiq.redis { |redis| redis.hdel(SidekiqUniqueJobs::HASH_KEY, jid) } end |
.logger ⇒ Object
36 37 38 |
# File 'lib/sidekiq_unique_jobs/unlockable.rb', line 36 def logger Sidekiq.logger end |
.unlock(item) ⇒ Object
5 6 7 |
# File 'lib/sidekiq_unique_jobs/unlockable.rb', line 5 def unlock(item) unlock_by_key(item[UNIQUE_DIGEST_KEY], item[JID_KEY]) end |
.unlock_by_key(unique_key, jid, redis_pool = nil) ⇒ Object
9 10 11 12 |
# File 'lib/sidekiq_unique_jobs/unlockable.rb', line 9 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 |