Class: SidekiqUniqueJobs::Lock::WhileExecuting
- Defined in:
- lib/sidekiq_unique_jobs/lock/while_executing.rb
Overview
Direct Known Subclasses
Instance Method Summary collapse
-
#execute { ... } ⇒ Object
Executes in the Sidekiq server process.
-
#initialize(item, callback, redis_pool = nil) ⇒ WhileExecuting
constructor
A new instance of WhileExecuting.
-
#lock ⇒ true
Simulate that a client lock was achieved.
Methods inherited from BaseLock
#delete, #delete!, #locked?, #unlock
Methods included from SidekiqUniqueJobs::Logging
#log_debug, #log_error, #log_fatal, #log_info, #log_warn, #logger, #logging_context
Constructor Details
#initialize(item, callback, redis_pool = nil) ⇒ WhileExecuting
Returns a new instance of WhileExecuting.
20 21 22 23 |
# File 'lib/sidekiq_unique_jobs/lock/while_executing.rb', line 20 def initialize(item, callback, redis_pool = nil) super(item, callback, redis_pool) append_unique_key_suffix end |
Instance Method Details
#execute { ... } ⇒ Object
Executes in the Sidekiq server process.
These jobs are locked in the server process not from the client
35 36 37 38 39 40 41 42 43 |
# File 'lib/sidekiq_unique_jobs/lock/while_executing.rb', line 35 def execute return strategy&.call unless locksmith.lock(item[LOCK_TIMEOUT_KEY]) yield unlock_with_callback rescue Exception # rubocop:disable Lint/RescueException delete! raise end |
#lock ⇒ true
Simulate that a client lock was achieved.
These locks should only ever be created in the server process.
28 29 30 |
# File 'lib/sidekiq_unique_jobs/lock/while_executing.rb', line 28 def lock true end |