class SidekiqUniqueJobs::Lock::WhileExecuting
@author Mikael Henriksson <mikael@zoolutions.se>
See {#execute} for more information about the server
See {#lock} for more information about the client.
- Unlocks after yielding to the worker’s perform method
- Locks before yielding to the worker’s perform method
Locks jobs while the job is executing in the server process
def append_unique_key_suffix
This is safe as the base_lock always creates a new digest
def append_unique_key_suffix item[LOCK_DIGEST] = item[LOCK_DIGEST] + RUN_SUFFIX end
def execute
- Yield: - to the worker class perform method
def execute with_logging_context do server_strategy&.call unless locksmith.lock do yield callback_safely end end ensure locksmith.unlock end
def initialize(item, callback, redis_pool = nil)
-
redis_pool
(Sidekiq::RedisConnection, ConnectionPool
) -- the redis connection -
callback
(Proc
) -- callback to call after unlock -
item
(Hash
) -- the Sidekiq job hash
def initialize(item, callback, redis_pool = nil) super(item, callback, redis_pool) append_unique_key_suffix end
def lock
-
(true)
- always returns true
def lock true end