Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-03-18 23:02:30 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-03-18 23:02:30 +0300
commit41fe97390ceddf945f3d967b8fdb3de4c66b7dea (patch)
tree9c8d89a8624828992f06d892cd2f43818ff5dcc8 /lib/gitlab/etag_caching
parent0804d2dc31052fb45a1efecedc8e06ce9bc32862 (diff)
Add latest changes from gitlab-org/gitlab@14-9-stable-eev14.9.0-rc42
Diffstat (limited to 'lib/gitlab/etag_caching')
-rw-r--r--lib/gitlab/etag_caching/middleware.rb5
-rw-r--r--lib/gitlab/etag_caching/router.rb19
-rw-r--r--lib/gitlab/etag_caching/router/rails.rb (renamed from lib/gitlab/etag_caching/router/restful.rb)48
3 files changed, 50 insertions, 22 deletions
diff --git a/lib/gitlab/etag_caching/middleware.rb b/lib/gitlab/etag_caching/middleware.rb
index d5bf0cffb1e..a1918ee6ad5 100644
--- a/lib/gitlab/etag_caching/middleware.rb
+++ b/lib/gitlab/etag_caching/middleware.rb
@@ -67,7 +67,10 @@ module Gitlab
add_instrument_for_cache_hit(status_code, route, request)
- Gitlab::ApplicationContext.push(feature_category: route.feature_category)
+ Gitlab::ApplicationContext.push(
+ feature_category: route.feature_category,
+ caller_id: route.caller_id
+ )
new_headers = {
'ETag' => etag,
diff --git a/lib/gitlab/etag_caching/router.rb b/lib/gitlab/etag_caching/router.rb
index 742b72ecde9..684afc6762a 100644
--- a/lib/gitlab/etag_caching/router.rb
+++ b/lib/gitlab/etag_caching/router.rb
@@ -3,22 +3,33 @@
module Gitlab
module EtagCaching
module Router
- Route = Struct.new(:regexp, :name, :feature_category, :router) do
+ Route = Struct.new(:router, :regexp, :name, :feature_category, :caller_id) do
delegate :match, to: :regexp
delegate :cache_key, to: :router
end
module Helpers
def build_route(attrs)
- EtagCaching::Router::Route.new(*attrs, self)
+ EtagCaching::Router::Route.new(self, *attrs)
+ end
+
+ def build_rails_route(attrs)
+ regexp, name, controller, action_name = *attrs
+ EtagCaching::Router::Route.new(
+ self,
+ regexp,
+ name,
+ controller.feature_category_for_action(action_name).to_s,
+ controller.endpoint_id_for_action(action_name).to_s
+ )
end
end
- # Performing RESTful routing match before GraphQL would be more expensive
+ # Performing Rails routing match before GraphQL would be more expensive
# for the GraphQL requests because we need to traverse all of the RESTful
# route definitions before falling back to GraphQL.
def self.match(request)
- Router::Graphql.match(request) || Router::Restful.match(request)
+ Router::Graphql.match(request) || Router::Rails.match(request)
end
end
end
diff --git a/lib/gitlab/etag_caching/router/restful.rb b/lib/gitlab/etag_caching/router/rails.rb
index 176676bd6ba..d80c003fe53 100644
--- a/lib/gitlab/etag_caching/router/restful.rb
+++ b/lib/gitlab/etag_caching/router/rails.rb
@@ -3,7 +3,7 @@
module Gitlab
module EtagCaching
module Router
- class Restful
+ class Rails
extend EtagCaching::Router::Helpers
# We enable an ETag for every request matching the regex.
@@ -23,74 +23,88 @@ module Gitlab
[
%r(#{RESERVED_WORDS_PREFIX}/noteable/issue/\d+/notes\z),
'issue_notes',
- 'team_planning'
+ ::Projects::NotesController,
+ :index
],
[
%r(#{RESERVED_WORDS_PREFIX}/noteable/merge_request/\d+/notes\z),
'merge_request_notes',
- 'code_review'
+ ::Projects::NotesController,
+ :index
],
[
%r(#{RESERVED_WORDS_PREFIX}/issues/\d+/realtime_changes\z),
'issue_title',
- 'team_planning'
+ ::Projects::IssuesController,
+ :realtime_changes
],
[
%r(#{RESERVED_WORDS_PREFIX}/commit/\S+/pipelines\.json\z),
'commit_pipelines',
- 'continuous_integration'
+ ::Projects::CommitController,
+ :pipelines
],
[
%r(#{RESERVED_WORDS_PREFIX}/merge_requests/new\.json\z),
'new_merge_request_pipelines',
- 'continuous_integration'
+ ::Projects::MergeRequests::CreationsController,
+ :new
],
[
%r(#{RESERVED_WORDS_PREFIX}/merge_requests/\d+/pipelines\.json\z),
'merge_request_pipelines',
- 'continuous_integration'
+ ::Projects::MergeRequestsController,
+ :pipelines
],
[
%r(#{RESERVED_WORDS_PREFIX}/pipelines\.json\z),
'project_pipelines',
- 'continuous_integration'
+ ::Projects::PipelinesController,
+ :index
],
[
%r(#{RESERVED_WORDS_PREFIX}/pipelines/\d+\.json\z),
'project_pipeline',
- 'continuous_integration'
+ ::Projects::PipelinesController,
+ :show
],
[
%r(#{RESERVED_WORDS_PREFIX}/builds/\d+\.json\z),
'project_build',
- 'continuous_integration'
+ ::Projects::BuildsController,
+ :show
],
[
%r(#{RESERVED_WORDS_PREFIX}/clusters/\d+/environments\z),
'cluster_environments',
- 'continuous_delivery'
+ ::Groups::ClustersController,
+ :environments
],
[
%r(#{RESERVED_WORDS_PREFIX}/-/environments\.json\z),
'environments',
- 'continuous_delivery'
+ ::Projects::EnvironmentsController,
+ :index
],
[
%r(#{RESERVED_WORDS_PREFIX}/import/github/realtime_changes\.json\z),
'realtime_changes_import_github',
- 'importers'
+ ::Import::GithubController,
+ :realtime_changes
],
[
%r(#{RESERVED_WORDS_PREFIX}/import/gitea/realtime_changes\.json\z),
'realtime_changes_import_gitea',
- 'importers'
+ ::Import::GiteaController,
+ :realtime_changes
],
[
%r(#{RESERVED_WORDS_PREFIX}/merge_requests/\d+/cached_widget\.json\z),
'merge_request_widget',
- 'code_review'
+ ::Projects::MergeRequests::ContentController,
+ :cached_widget
]
- ].map(&method(:build_route)).freeze
+ ].map(&method(:build_rails_route)).freeze
# Overridden in EE to add more routes
def self.all_routes
@@ -109,4 +123,4 @@ module Gitlab
end
end
-Gitlab::EtagCaching::Router::Restful.prepend_mod_with('Gitlab::EtagCaching::Router::Restful')
+Gitlab::EtagCaching::Router::Rails.prepend_mod_with('Gitlab::EtagCaching::Router::Rails')