Class: SidekiqUniqueJobs::Lock::UntilExpired

Inherits:
BaseLock
  • Object
show all
Defined in:
lib/sidekiq_unique_jobs/lock/until_expired.rb

Overview

Locks jobs until the lock has expired

  • Locks on perform_in or perform_async

  • Unlocks when the expiration is hit

See BaseLock#lock for more information about the client. See #execute for more information about the server

Author:

Instance Method Summary collapse

Methods inherited from BaseLock

#delete, #delete!, #initialize, #lock, #locked?

Methods included from SidekiqUniqueJobs::Logging

#log_debug, #log_error, #log_fatal, #log_info, #log_warn, #logger, #logging_context

Constructor Details

This class inherits a constructor from SidekiqUniqueJobs::Lock::BaseLock

Instance Method Details

#execute { ... } ⇒ Object

Executes in the Sidekiq server process

Yields:

  • to the worker class perform method



22
23
24
25
26
27
# File 'lib/sidekiq_unique_jobs/lock/until_expired.rb', line 22

def execute
  return unless locked?

  yield
  # this lock does not handle after_unlock since we don't know when that would happen
end

#unlocktrue

Prevents these locks from being unlocked

Returns:

  • (true)

    always returns true



16
17
18
# File 'lib/sidekiq_unique_jobs/lock/until_expired.rb', line 16

def unlock
  true
end