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
Constructor Details
#initialize(item, callback, redis_pool = nil) ⇒ WhileExecuting
Returns a new instance of WhileExecuting.
19 20 21 22 |
# File 'lib/sidekiq_unique_jobs/lock/while_executing.rb', line 19 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
34 35 36 37 |
# File 'lib/sidekiq_unique_jobs/lock/while_executing.rb', line 34 def execute return strategy.call unless locksmith.lock(item[LOCK_TIMEOUT_KEY]) with_cleanup { yield } end |
#lock ⇒ true
Simulate that a client lock was achieved.
These locks should only ever be created in the server process.
27 28 29 |
# File 'lib/sidekiq_unique_jobs/lock/while_executing.rb', line 27 def lock true end |