summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2016-07-26 09:33:21 +0000
committerYorick Peterse <yorickpeterse@gmail.com>2016-07-26 09:33:21 +0000
commitebf852703c51d6d59b76930be48b295a6b6561e4 (patch)
tree64658210dc9948b8495a2f14b55faefe88cfd306
parent08c8b97413d9814f228efc68675a5dc079bb487b (diff)
parent22386040fe5c1cd5b3ab163211b77c6ff254e88e (diff)
downloadgitlab-ce-ebf852703c51d6d59b76930be48b295a6b6561e4.tar.gz
Merge branch 'add-sidekiq-request-store' into 'master'
Add support for using RequestStore within Sidekiq tasks via SIDEKIQ_REQUEST_STORE env variable See merge request !5054
-rw-r--r--CHANGELOG1
-rw-r--r--config/initializers/sidekiq.rb1
-rw-r--r--lib/gitlab/sidekiq_middleware/request_store_middleware.rb13
3 files changed, 15 insertions, 0 deletions
diff --git a/CHANGELOG b/CHANGELOG
index ef8c72f4aa2..aab0a408b18 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -4,6 +4,7 @@ v 8.11.0 (unreleased)
- Remove magic comments (`# encoding: UTF-8`) from Ruby files. !5456 (winniehell)
- Fix CI status icon link underline (ClemMakesApps)
- Fix of 'Commits being passed to custom hooks are already reachable when using the UI'
+ - Add support for using RequestStore within Sidekiq tasks via SIDEKIQ_REQUEST_STORE env variable
- Limit git rev-list output count to one in forced push check
- Add green outline to New Branch button. !5447 (winniehell)
- Retrieve rendered HTML from cache in one request
diff --git a/config/initializers/sidekiq.rb b/config/initializers/sidekiq.rb
index 5e839327e7a..cf49ec2194c 100644
--- a/config/initializers/sidekiq.rb
+++ b/config/initializers/sidekiq.rb
@@ -7,6 +7,7 @@ Sidekiq.configure_server do |config|
config.server_middleware do |chain|
chain.add Gitlab::SidekiqMiddleware::ArgumentsLogger if ENV['SIDEKIQ_LOG_ARGUMENTS']
chain.add Gitlab::SidekiqMiddleware::MemoryKiller if ENV['SIDEKIQ_MEMORY_KILLER_MAX_RSS']
+ chain.add Gitlab::SidekiqMiddleware::RequestStoreMiddleware unless ENV['SIDEKIQ_REQUEST_STORE'] == '0'
end
# Sidekiq-cron: load recurring jobs from gitlab.yml
diff --git a/lib/gitlab/sidekiq_middleware/request_store_middleware.rb b/lib/gitlab/sidekiq_middleware/request_store_middleware.rb
new file mode 100644
index 00000000000..b1fa0e3cb4e
--- /dev/null
+++ b/lib/gitlab/sidekiq_middleware/request_store_middleware.rb
@@ -0,0 +1,13 @@
+module Gitlab
+ module SidekiqMiddleware
+ class RequestStoreMiddleware
+ def call(worker, job, queue)
+ RequestStore.begin!
+ yield
+ ensure
+ RequestStore.end!
+ RequestStore.clear!
+ end
+ end
+ end
+end