debian-mirror-gitlab/app/workers/pipeline_schedule_worker.rb

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

46 lines
1 KiB
Ruby
Raw Normal View History

2018-11-08 19:23:39 +05:30
# frozen_string_literal: true
2020-04-08 14:13:33 +05:30
class PipelineScheduleWorker # rubocop:disable Scalability/IdempotentWorker
2018-03-17 18:26:18 +05:30
include ApplicationWorker
2021-06-08 01:23:25 +05:30
2021-10-27 15:23:28 +05:30
data_consistency :always
2017-08-17 22:00:37 +05:30
include CronjobQueue
2023-03-17 16:20:25 +05:30
include ::Gitlab::ExclusiveLeaseHelpers
LOCK_RETRY = 3
LOCK_TTL = 5.minutes
2019-07-07 11:18:12 +05:30
2019-12-21 20:55:43 +05:30
feature_category :continuous_integration
2019-12-26 22:10:19 +05:30
worker_resource_boundary :cpu
2019-12-21 20:55:43 +05:30
2017-08-17 22:00:37 +05:30
def perform
2023-04-23 21:23:45 +05:30
in_lock(lock_key, **lock_params) do
Ci::PipelineSchedule
.select(:id, :owner_id, :project_id) # Minimize the selected columns
.runnable_schedules
.preloaded
.find_in_batches do |schedules|
RunPipelineScheduleWorker.bulk_perform_async_with_contexts(
schedules,
arguments_proc: ->(schedule) { [schedule.id, schedule.owner_id, { scheduling: true }] },
context_proc: ->(schedule) { { project: schedule.project, user: schedule.owner } }
)
2020-03-13 15:44:24 +05:30
end
2017-08-17 22:00:37 +05:30
end
end
2023-03-17 16:20:25 +05:30
private
def lock_key
self.class.name.underscore
end
def lock_params
{
ttl: LOCK_TTL,
retries: LOCK_RETRY
}
end
2017-08-17 22:00:37 +05:30
end