debian-mirror-gitlab/lib/feature/gitaly.rb

31 lines
798 B
Ruby
Raw Normal View History

2019-09-04 21:01:54 +05:30
# frozen_string_literal: true
class Feature
class Gitaly
2020-03-09 13:42:32 +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-09 13:42:32 +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-04-08 14:13:33 +05:30
# We need to check that both the DB connection and table exists
return {} unless ::Gitlab::Database.cached_table_exists?(FlipperFeature.table_name)
2020-03-09 13:42:32 +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