Module: RedisQueuedLocks::Acquirer::AcquireLock::WithAcqTimeout Private
- Included in:
- RedisQueuedLocks::Acquirer::AcquireLock
- Defined in:
- lib/redis_queued_locks/acquirer/acquire_lock/with_acq_timeout.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
Instance Method Details
#with_acq_timeout(redis, timeout, lock_key, lock_name, raise_errors, detailed_acq_timeout_error, on_timeout: nil) { ... } ⇒ Any
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/redis_queued_locks/acquirer/acquire_lock/with_acq_timeout.rb', line 30 def with_acq_timeout( redis, timeout, lock_key, lock_name, raise_errors, detailed_acq_timeout_error, on_timeout: nil, &block ) ::Timeout.timeout(timeout, RedisQueuedLocks::LockAcquirementIntermediateTimeoutError, &block) rescue RedisQueuedLocks::LockAcquirementIntermediateTimeoutError if on_timeout != nil # @type var on_timeout: Proc on_timeout.call end if raise_errors if detailed_acq_timeout_error # TODO: rewrite these invocations to separated inner-AcquireLock-related modules # in order to remove any dependencies from the other public RQL commands cuz # all AcquireLock logic elements should be fully independent from others as a core; lock_info = RedisQueuedLocks::Acquirer::LockInfo.lock_info(redis, lock_name) queue_info = RedisQueuedLocks::Acquirer::QueueInfo.queue_info(redis, lock_name) # rubocop:disable Metrics/BlockNesting raise( RedisQueuedLocks::LockAcquirementTimeoutError, "Failed to acquire the lock \"#{lock_key}\" " \ "for the given <#{timeout} seconds> timeout. Details: " \ "<Lock Data> => #{lock_info ? lock_info.inspect : '<no_data>'}; " \ "<Queue Data> => #{queue_info ? queue_info.inspect : '<no_data>'};" ) # rubocop:enable Metrics/BlockNesting else raise( RedisQueuedLocks::LockAcquirementTimeoutError, "Failed to acquire the lock \"#{lock_key}\" " \ "for the given <#{timeout} seconds> timeout." ) end end end |