diff options
author | Stan Hu <stanhu@gmail.com> | 2016-07-01 22:51:21 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2016-07-26 03:59:09 +0300 |
commit | f4aac773894bb17f550fff8ee548f2a18cd18b64 (patch) | |
tree | 14a44f8db624e6486318a387ddfbf9ee8cc9ce91 /lib/gitlab/sidekiq_middleware/request_store_middleware.rb | |
parent | 68162ba900f1b9003fa3d07613333f201be8154a (diff) |
Add support for using RequestStore within Sidekiq tasks via SIDEKIQ_REQUEST_STORE env variable
This significantly reduces the DB churn in the PostReceive task when it
performs reference extraction.
See #18663
Diffstat (limited to 'lib/gitlab/sidekiq_middleware/request_store_middleware.rb')
-rw-r--r-- | lib/gitlab/sidekiq_middleware/request_store_middleware.rb | 13 |
1 files changed, 13 insertions, 0 deletions
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 |