2018-07-22 00:39:30 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-06-26 13:12:29 +00:00
|
|
|
module RepositoryCheck
|
|
|
|
class DispatchWorker
|
|
|
|
include ApplicationWorker
|
2020-02-04 15:08:40 +00:00
|
|
|
include CronjobQueue # rubocop:disable Scalability/CronWorkerContext
|
2018-06-26 13:12:29 +00:00
|
|
|
include ::EachShardWorker
|
2018-07-06 16:05:58 +00:00
|
|
|
include ExclusiveLeaseGuard
|
|
|
|
|
2019-10-18 11:11:44 +00:00
|
|
|
feature_category :source_code_management
|
|
|
|
|
2018-07-06 16:05:58 +00:00
|
|
|
LEASE_TIMEOUT = 1.hour
|
2018-06-26 13:12:29 +00:00
|
|
|
|
|
|
|
def perform
|
|
|
|
return unless Gitlab::CurrentSettings.repository_checks_enabled
|
|
|
|
|
2018-07-06 16:05:58 +00:00
|
|
|
try_obtain_lease do
|
|
|
|
each_eligible_shard do |shard_name|
|
|
|
|
RepositoryCheck::BatchWorker.perform_async(shard_name)
|
|
|
|
end
|
2018-06-26 13:12:29 +00:00
|
|
|
end
|
|
|
|
end
|
2018-07-06 16:05:58 +00:00
|
|
|
|
|
|
|
def lease_timeout
|
|
|
|
LEASE_TIMEOUT
|
|
|
|
end
|
2018-06-26 13:12:29 +00:00
|
|
|
end
|
|
|
|
end
|