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, project = nil) ⇒ Boolean

Returns:

  • (Boolean)

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

def enabled?(feature_flag, project = nil)
  return false unless Feature::FlipperFeature.table_exists?

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

.server_feature_flags(project = nil) ⇒ Object


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

def server_feature_flags(project = nil)
  # We need to check that both the DB connection and table exists
  return {} unless FlipperFeature.database.cached_table_exists?

  Feature.persisted_names
    .select { |f| f.start_with?(PREFIX) }
    .to_h do |f|
    flag = f.delete_prefix(PREFIX)

    ["gitaly-feature-#{flag.tr('_', '-')}", enabled?(flag, project).to_s]
  end
end