Commit f06ce294 authored by Krasimir Angelov's avatar Krasimir Angelov

Use Enumerable#max instead of custom implementation

See
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/58578#note_558440931.
parent ec5edc5f
...@@ -38,7 +38,7 @@ module Database ...@@ -38,7 +38,7 @@ module Database
end end
def with_exclusive_lease(interval) 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) lease = Gitlab::ExclusiveLease.new(lease_key, timeout: timeout)
yield if lease.try_obtain yield if lease.try_obtain
...@@ -46,10 +46,6 @@ module Database ...@@ -46,10 +46,6 @@ module Database
lease&.cancel lease&.cancel
end end
def max(left, right)
left >= right ? left : right
end
def lease_key def lease_key
self.class.name.demodulize.underscore self.class.name.demodulize.underscore
end 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