Commit 53234295 authored by Shinya Maeda's avatar Shinya Maeda

Rename retries and remove retry_max

parent 902e69de
......@@ -3,15 +3,14 @@ module ExclusiveLeaseLock
FailedToObtainLockError = Class.new(StandardError)
def in_lock(key, ttl: 1.minute, retry_max: 10, sleep_sec: 0.01.seconds)
def in_lock(key, ttl: 1.minute, retries: 10, sleep_sec: 0.01.seconds)
lease = Gitlab::ExclusiveLease.new(key, timeout: ttl)
retry_count = 0
until uuid = lease.try_obtain
# Keep trying until we obtain the lease. To prevent hammering Redis too
# much we'll wait for a bit.
sleep(sleep_sec)
break if retry_max < (retry_count += 1)
break if (retries -= 1) < 0
end
raise FailedToObtainLockError, 'Failed to obtain a lock' unless uuid
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment