Refactor ExpirePipelineCacheWorker for EE
This refactors ExpirePipelineCacheWorker so that EE can more easily extend its logic, without having to inject code in the middle of a CE method.
This commit is contained in:
parent
d67d0dfb2b
commit
4f623342c7
|
@ -11,16 +11,9 @@ class ExpirePipelineCacheWorker
|
|||
pipeline = Ci::Pipeline.find_by(id: pipeline_id)
|
||||
return unless pipeline
|
||||
|
||||
project = pipeline.project
|
||||
store = Gitlab::EtagCaching::Store.new
|
||||
|
||||
store.touch(project_pipelines_path(project))
|
||||
store.touch(project_pipeline_path(project, pipeline))
|
||||
store.touch(commit_pipelines_path(project, pipeline.commit)) unless pipeline.commit.nil?
|
||||
store.touch(new_merge_request_pipelines_path(project))
|
||||
each_pipelines_merge_request_path(project, pipeline) do |path|
|
||||
store.touch(path)
|
||||
end
|
||||
update_etag_cache(pipeline, store)
|
||||
|
||||
Gitlab::Cache::Ci::ProjectPipelineStatus.update_for_pipeline(pipeline)
|
||||
end
|
||||
|
@ -51,4 +44,23 @@ class ExpirePipelineCacheWorker
|
|||
yield(path)
|
||||
end
|
||||
end
|
||||
|
||||
# Updates ETag caches of a pipeline.
|
||||
#
|
||||
# This logic resides in a separate method so that EE can more easily extend
|
||||
# it.
|
||||
#
|
||||
# @param [Ci::Pipeline] pipeline
|
||||
# @param [Gitlab::EtagCaching::Store] store
|
||||
def update_etag_cache(pipeline, store)
|
||||
project = pipeline.project
|
||||
|
||||
store.touch(project_pipelines_path(project))
|
||||
store.touch(project_pipeline_path(project, pipeline))
|
||||
store.touch(commit_pipelines_path(project, pipeline.commit)) unless pipeline.commit.nil?
|
||||
store.touch(new_merge_request_pipelines_path(project))
|
||||
each_pipelines_merge_request_path(project, pipeline) do |path|
|
||||
store.touch(path)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue