summaryrefslogtreecommitdiff
path: root/lib/feature
diff options
context:
space:
mode:
authorZeger-Jan van de Weg <git@zjvandeweg.nl>2019-06-12 16:20:01 +0200
committerZeger-Jan van de Weg <git@zjvandeweg.nl>2019-06-18 13:33:43 +0200
commit4dfaaf40b9c6754157adff3704a8036b440148b3 (patch)
tree64587b50e0c0f5d17fa9106fda0a41bfee7de154 /lib/feature
parent968674e41798c437b9ebf4a9731fe2f2a4f07024 (diff)
downloadgitlab-ce-4dfaaf40b9c6754157adff3704a8036b440148b3.tar.gz
Turn on Cat-File cache by default
The feature flag has been introduced an was turned off by default, now the it will default to be turned on. That change would still allow users to turn this feature off by leveraging the Rails console by running: `Feature.disable("gitaly_catfile-cache")` Another option is to manage the number of items the LRU cache will contain, by updating the `config.toml` for Gitaly. This would be the `catfile_cache_size`: https://gitlab.com/gitlab-org/gitaly/blob/0dcb5c579e63754f557aef91a4fa7a00e5b8b127/config.toml.example#L27 Closes: https://gitlab.com/gitlab-org/gitaly/issues/1712
Diffstat (limited to 'lib/feature')
-rw-r--r--lib/feature/gitaly.rb22
1 files changed, 14 insertions, 8 deletions
diff --git a/lib/feature/gitaly.rb b/lib/feature/gitaly.rb
index 33868e49f14..d7a8f8a0b9e 100644
--- a/lib/feature/gitaly.rb
+++ b/lib/feature/gitaly.rb
@@ -1,24 +1,30 @@
+# frozen_string_literal: true
+
+require 'set'
+
class Feature
class Gitaly
+ # Server feature flags should use '_' to separate words.
+ # CATFILE_CACHE sets an incorrect example
CATFILE_CACHE = 'catfile-cache'.freeze
- # Server feature flags should use '_' to separate words.
SERVER_FEATURE_FLAGS = [CATFILE_CACHE].freeze
+ DEFAULT_ON_FLAGS = Set.new([CATFILE_CACHE]).freeze
class << self
def enabled?(feature_flag)
- Feature::FlipperFeature.table_exists? && Feature.enabled?("gitaly_#{feature_flag}")
+ return false unless Feature::FlipperFeature.table_exists?
+
+ default_on = DEFAULT_ON_FLAGS.include?(feature_flag)
+ Feature.enabled?("gitaly_#{feature_flag}", default_enabled: default_on)
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
+ SERVER_FEATURE_FLAGS.map do |f|
+ ["gitaly-feature-#{f.tr('_', '-')}", enabled?(f).to_s]
+ end.to_h
end
end
end