2019-06-12 10:20:01 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-06-12 09:32:29 -04:00
|
|
|
class Feature
|
|
|
|
class Gitaly
|
2020-02-12 07:09:01 -05:00
|
|
|
PREFIX = "gitaly_"
|
2019-06-12 09:32:29 -04:00
|
|
|
|
|
|
|
class << self
|
|
|
|
def enabled?(feature_flag)
|
2019-06-12 10:20:01 -04:00
|
|
|
return false unless Feature::FlipperFeature.table_exists?
|
|
|
|
|
2020-02-12 07:09:01 -05:00
|
|
|
Feature.enabled?("#{PREFIX}#{feature_flag}")
|
2019-10-22 02:06:38 -04:00
|
|
|
rescue ActiveRecord::NoDatabaseError, PG::ConnectionBad
|
2019-06-12 09:32:29 -04:00
|
|
|
false
|
|
|
|
end
|
|
|
|
|
|
|
|
def server_feature_flags
|
2020-03-31 08:08:09 -04:00
|
|
|
# We need to check that both the DB connection and table exists
|
|
|
|
return {} unless ::Gitlab::Database.cached_table_exists?(FlipperFeature.table_name)
|
|
|
|
|
2020-02-12 07:09:01 -05:00
|
|
|
Feature.persisted_names
|
|
|
|
.select { |f| f.start_with?(PREFIX) }
|
|
|
|
.map do |f|
|
|
|
|
flag = f.delete_prefix(PREFIX)
|
|
|
|
|
|
|
|
["gitaly-feature-#{flag.tr('_', '-')}", enabled?(flag).to_s]
|
2019-06-12 10:20:01 -04:00
|
|
|
end.to_h
|
2019-06-12 09:32:29 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|