Extract lease timeout to a constant

parent a3f1188e
...@@ -2,6 +2,8 @@ module Geo ...@@ -2,6 +2,8 @@ module Geo
class RepositoryBackfillService class RepositoryBackfillService
attr_reader :project attr_reader :project
LEASE_TIMEOUT = 24.hours.freeze
def initialize(project) def initialize(project)
@project = project @project = project
end end
...@@ -40,10 +42,7 @@ module Geo ...@@ -40,10 +42,7 @@ module Geo
end end
def try_obtain_lease def try_obtain_lease
uuid = Gitlab::ExclusiveLease.new( uuid = Gitlab::ExclusiveLease.new(lease_key, timeout: LEASE_TIMEOUT).try_obtain
lease_key,
timeout: 24.hours
).try_obtain
return unless uuid return unless uuid
......
...@@ -32,8 +32,7 @@ class GeoBackfillWorker ...@@ -32,8 +32,7 @@ class GeoBackfillWorker
end end
def try_obtain_lease def try_obtain_lease
uuid = Gitlab::ExclusiveLease.new(lease_key, timeout: LEASE_TIMEOUT) uuid = Gitlab::ExclusiveLease.new(lease_key, timeout: LEASE_TIMEOUT).try_obtain
.try_obtain
return unless uuid return 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