diff options
author | Zeger-Jan van de Weg <git@zjvandeweg.nl> | 2019-06-12 15:32:29 +0200 |
---|---|---|
committer | Zeger-Jan van de Weg <git@zjvandeweg.nl> | 2019-06-18 13:18:18 +0200 |
commit | 968674e41798c437b9ebf4a9731fe2f2a4f07024 (patch) | |
tree | 0fdc959be0443bff849cf704ed762902ff265ef3 /lib/feature | |
parent | 28f7846c4723457c6d53808215796515396eaa7d (diff) | |
download | gitlab-ce-968674e41798c437b9ebf4a9731fe2f2a4f07024.tar.gz |
Move Gitaly feature flag logic to Feature::Gitaly
The GitalyClient held a lot of logic which was all very tightly coupled.
In this instance the feature logic was extracted to make it do just a
little less and create a bit more focus in the GitalyClient's
responsibilies.
Diffstat (limited to 'lib/feature')
-rw-r--r-- | lib/feature/gitaly.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/feature/gitaly.rb b/lib/feature/gitaly.rb new file mode 100644 index 00000000000..33868e49f14 --- /dev/null +++ b/lib/feature/gitaly.rb @@ -0,0 +1,25 @@ +class Feature + class Gitaly + CATFILE_CACHE = 'catfile-cache'.freeze + + # Server feature flags should use '_' to separate words. + SERVER_FEATURE_FLAGS = [CATFILE_CACHE].freeze + + class << self + def enabled?(feature_flag) + Feature::FlipperFeature.table_exists? && Feature.enabled?("gitaly_#{feature_flag}") + rescue ActiveRecord::NoDatabaseError + false + end + + def server_feature_flags + @server_feature_flags ||= + begin + SERVER_FEATURE_FLAGS.map do |f| + ["gitaly-feature-#{f.tr('_', '-')}", enabled?(f).to_s] + end.to_h + end + end + end + end +end |