2018-06-27 07:23:28 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2021-08-24 15:10:36 +00:00
|
|
|
class ExpireJobCacheWorker # rubocop:disable Scalability/IdempotentWorker
|
2017-11-28 16:08:30 +00:00
|
|
|
include ApplicationWorker
|
2021-04-30 18:10:09 +00:00
|
|
|
|
2021-08-26 15:10:41 +00:00
|
|
|
data_consistency :delayed
|
2021-07-21 12:09:35 +00:00
|
|
|
|
2021-04-30 18:10:09 +00:00
|
|
|
sidekiq_options retry: 3
|
2017-08-21 12:16:51 +00:00
|
|
|
include PipelineQueue
|
|
|
|
|
2017-11-28 16:16:50 +00:00
|
|
|
queue_namespace :pipeline_cache
|
2020-03-02 18:07:42 +00:00
|
|
|
urgency :high
|
2021-09-29 15:11:47 +00:00
|
|
|
|
|
|
|
deduplicate :until_executing, including_scheduled: true
|
|
|
|
idempotent!
|
2017-05-20 22:07:36 +00:00
|
|
|
|
2017-05-22 18:22:50 +00:00
|
|
|
def perform(job_id)
|
2021-11-10 15:13:21 +00:00
|
|
|
job = CommitStatus.preload(:pipeline, :project).find_by_id(job_id) # rubocop: disable CodeReuse/ActiveRecord
|
2017-05-20 22:07:36 +00:00
|
|
|
return unless job
|
|
|
|
|
|
|
|
pipeline = job.pipeline
|
|
|
|
project = job.project
|
|
|
|
|
2021-02-26 18:11:10 +00:00
|
|
|
Gitlab::EtagCaching::Store.new.touch(project_job_path(project, job))
|
|
|
|
ExpirePipelineCacheWorker.perform_async(pipeline.id)
|
2017-05-20 22:07:36 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def project_job_path(project, job)
|
2017-06-29 17:06:35 +00:00
|
|
|
Gitlab::Routing.url_helpers.project_build_path(project, job.id, format: :json)
|
2017-05-20 22:07:36 +00:00
|
|
|
end
|
|
|
|
end
|