summaryrefslogtreecommitdiff
path: root/lib/feature.rb
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2018-05-31 18:12:48 +0200
committerRémy Coutable <remy@rymai.me>2018-06-01 17:51:40 +0200
commite1ffd6a271e352a725aa0394b654e9250f2d8240 (patch)
treeb4cb954e6042950cd63ce9a51c6832c59f90558b /lib/feature.rb
parentc5f89e5bd7f9371882de8b6ad62d24467b22937b (diff)
downloadgitlab-ce-e1ffd6a271e352a725aa0394b654e9250f2d8240.tar.gz
Use RequestStore to memoize Flipper features so that memoized values are cleared between requests
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'lib/feature.rb')
-rw-r--r--lib/feature.rb11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/feature.rb b/lib/feature.rb
index 6474de6e56d..314ae224d90 100644
--- a/lib/feature.rb
+++ b/lib/feature.rb
@@ -63,8 +63,15 @@ class Feature
end
def flipper
- Thread.current[:flipper] ||=
- Flipper.new(flipper_adapter).tap { |flip| flip.memoize = true }
+ if RequestStore.active?
+ RequestStore[:flipper] ||= build_flipper_instance
+ else
+ @flipper ||= build_flipper_instance
+ end
+ end
+
+ def build_flipper_instance
+ Flipper.new(flipper_adapter).tap { |flip| flip.memoize = true }
end
# This method is called from config/initializers/flipper.rb and can be used