Commit 13d3d8fc authored by Yannis Roussos's avatar Yannis Roussos

Merge branch '326840-use-enumerable-max' into 'master'

Use Enumerable#max instead of custom implementation

See merge request gitlab-org/gitlab!60078
parents c0643689 f06ce294
......@@ -38,7 +38,7 @@ module Database
end
def with_exclusive_lease(interval)
timeout = max(interval * LEASE_TIMEOUT_MULTIPLIER, MINIMUM_LEASE_TIMEOUT)
timeout = [interval * LEASE_TIMEOUT_MULTIPLIER, MINIMUM_LEASE_TIMEOUT].max
lease = Gitlab::ExclusiveLease.new(lease_key, timeout: timeout)
yield if lease.try_obtain
......@@ -46,10 +46,6 @@ module Database
lease&.cancel
end
def max(left, right)
left >= right ? left : right
end
def lease_key
self.class.name.demodulize.underscore
end
......
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