Class: SidekiqUniqueJobs::Lock::WhileExecutingReject

Inherits:
WhileExecuting show all
Defined in:
lib/sidekiq_unique_jobs/lock/while_executing_reject.rb

Overview

Locks jobs while executing

Locks from the server process
Unlocks after the server is done processing

See SidekiqUniqueJobs::Lock::WhileExecuting#lock for more information about the client. See #execute for more information about the server

Author:

Instance Method Summary collapse

Methods inherited from WhileExecuting

#initialize, #lock

Methods inherited from BaseLock

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

Methods included from SidekiqUniqueJobs::Logging

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

Constructor Details

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

Instance Method Details

#execute { ... } ⇒ Object

Executes in the Sidekiq server process

Yields:

  • to the worker class perform method



16
17
18
19
20
# File 'lib/sidekiq_unique_jobs/lock/while_executing_reject.rb', line 16

def execute
  return strategy.call unless locksmith.lock(item[LOCK_TIMEOUT_KEY])

  with_cleanup { yield }
end

#strategyOnConflict::Reject

Overridden with a forced OnConflict::Reject strategy

Returns:



24
25
26
# File 'lib/sidekiq_unique_jobs/lock/while_executing_reject.rb', line 24

def strategy
  @strategy ||= OnConflict.find_strategy(:reject).new(item)
end