Extract lease timeout to a constant

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