summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2019-01-18 16:33:15 +0100
committerYorick Peterse <yorickpeterse@gmail.com>2019-01-21 14:33:21 +0100
commit4f623342c77fe26f43bbf936e83221e8719c9eb3 (patch)
tree2c6fcbdca84a502f222bf9c7cd64674162d53bb7
parentd67d0dfb2bec0619ad2898220e6f5050a9e7689e (diff)
downloadgitlab-ce-4f623342c77fe26f43bbf936e83221e8719c9eb3.tar.gz
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.
-rw-r--r--app/workers/expire_pipeline_cache_worker.rb28
1 files changed, 20 insertions, 8 deletions
diff --git a/app/workers/expire_pipeline_cache_worker.rb b/app/workers/expire_pipeline_cache_worker.rb
index c96e8a0379b..148384600b6 100644
--- a/app/workers/expire_pipeline_cache_worker.rb
+++ b/app/workers/expire_pipeline_cache_worker.rb
@@ -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