diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-18 16:16:36 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-18 16:16:36 +0300 |
commit | 311b0269b4eb9839fa63f80c8d7a58f32b8138a0 (patch) | |
tree | 07e7870bca8aed6d61fdcc810731c50d2c40af47 /lib/feature.rb | |
parent | 27909cef6c4170ed9205afa7426b8d3de47cbb0c (diff) |
Add latest changes from gitlab-org/gitlab@14-5-stable-eev14.5.0-rc42
Diffstat (limited to 'lib/feature.rb')
-rw-r--r-- | lib/feature.rb | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/feature.rb b/lib/feature.rb index f8d34e9c386..8186fbc40fa 100644 --- a/lib/feature.rb +++ b/lib/feature.rb @@ -6,6 +6,8 @@ require 'flipper/adapters/active_support_cache_store' class Feature # Classes to override flipper table names class FlipperFeature < Flipper::Adapters::ActiveRecord::Feature + include DatabaseReflection + # Using `self.table_name` won't work. ActiveRecord bug? superclass.table_name = 'features' @@ -36,7 +38,7 @@ class Feature end def persisted_names - return [] unless Gitlab::Database.main.exists? + return [] unless ApplicationRecord.database.exists? # This loads names of all stored feature flags # and returns a stable Set in the following order: @@ -73,7 +75,7 @@ class Feature # During setup the database does not exist yet. So we haven't stored a value # for the feature yet and return the default. - return default_enabled unless Gitlab::Database.main.exists? + return default_enabled unless ApplicationRecord.database.exists? feature = get(key) @@ -155,13 +157,13 @@ class Feature def flipper if Gitlab::SafeRequestStore.active? - Gitlab::SafeRequestStore[:flipper] ||= build_flipper_instance + Gitlab::SafeRequestStore[:flipper] ||= build_flipper_instance(memoize: true) else @flipper ||= build_flipper_instance end end - def build_flipper_instance + def build_flipper_instance(memoize: false) active_record_adapter = Flipper::Adapters::ActiveRecord.new( feature_class: FlipperFeature, gate_class: FlipperGate) @@ -182,7 +184,7 @@ class Feature expires_in: 1.minute) Flipper.new(flipper_adapter).tap do |flip| - flip.memoize = true + flip.memoize = memoize end end |