debian-mirror-gitlab/app/workers/repository_check/dispatch_worker.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

35 lines
823 B
Ruby
Raw Normal View History

2018-11-18 11:00:15 +05:30
# frozen_string_literal: true
2018-11-08 19:23:39 +05:30
module RepositoryCheck
2020-04-08 14:13:33 +05:30
class DispatchWorker # rubocop:disable Scalability/IdempotentWorker
2018-11-08 19:23:39 +05:30
include ApplicationWorker
2021-06-08 01:23:25 +05:30
2021-10-27 15:23:28 +05:30
data_consistency :always
2020-03-13 15:44:24 +05:30
# rubocop:disable Scalability/CronWorkerContext
# This worker does not perform work scoped to a context
2018-11-08 19:23:39 +05:30
include CronjobQueue
2020-03-13 15:44:24 +05:30
# rubocop:enable Scalability/CronWorkerContext
2018-11-08 19:23:39 +05:30
include ::EachShardWorker
include ExclusiveLeaseGuard
2019-12-21 20:55:43 +05:30
feature_category :source_code_management
2018-11-08 19:23:39 +05:30
LEASE_TIMEOUT = 1.hour
def perform
return unless Gitlab::CurrentSettings.repository_checks_enabled
try_obtain_lease do
each_eligible_shard do |shard_name|
RepositoryCheck::BatchWorker.perform_async(shard_name)
end
end
end
def lease_timeout
LEASE_TIMEOUT
end
end
end