2019-09-04 21:01:54 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class Feature
|
|
|
|
class Gitaly
|
2020-03-13 15:44:24 +05:30
|
|
|
PREFIX = "gitaly_"
|
2019-09-04 21:01:54 +05:30
|
|
|
|
|
|
|
class << self
|
|
|
|
def enabled?(feature_flag)
|
|
|
|
return false unless Feature::FlipperFeature.table_exists?
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
Feature.enabled?("#{PREFIX}#{feature_flag}")
|
2019-12-26 22:10:19 +05:30
|
|
|
rescue ActiveRecord::NoDatabaseError, PG::ConnectionBad
|
2019-09-04 21:01:54 +05:30
|
|
|
false
|
|
|
|
end
|
|
|
|
|
|
|
|
def server_feature_flags
|
2020-03-13 15:44:24 +05:30
|
|
|
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-09-04 21:01:54 +05:30
|
|
|
end.to_h
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|