Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZeger-Jan van de Weg <git@zjvandeweg.nl>2019-06-12 16:32:29 +0300
committerZeger-Jan van de Weg <git@zjvandeweg.nl>2019-06-18 14:18:18 +0300
commit968674e41798c437b9ebf4a9731fe2f2a4f07024 (patch)
tree0fdc959be0443bff849cf704ed762902ff265ef3 /lib/feature
parent28f7846c4723457c6d53808215796515396eaa7d (diff)
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.rb25
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