Class: Feature::Gitaly

Inherits:
Object
  • Object
show all
Defined in:
lib/feature/gitaly.rb

Constant Summary collapse

PREFIX =
"gitaly_"

Class Method Summary collapse

Class Method Details

.enabled?(feature_flag) ⇒ Boolean

Returns:

  • (Boolean)

8
9
10
11
12
13
14
# File 'lib/feature/gitaly.rb', line 8

def enabled?(feature_flag)
  return false unless Feature::FlipperFeature.table_exists?

  Feature.enabled?("#{PREFIX}#{feature_flag}")
rescue ActiveRecord::NoDatabaseError, PG::ConnectionBad
  false
end

.server_feature_flagsObject


16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/feature/gitaly.rb', line 16

def server_feature_flags
  # We need to check that both the DB connection and table exists
  return {} unless ::Gitlab::Database.cached_table_exists?(FlipperFeature.table_name)

  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]
  end.to_h
end