Module: Gitlab::SetupHelper::Praefect

Extended by:
Gitlab::SetupHelper
Defined in:
lib/gitlab/setup_helper.rb

Class Method Summary collapse

Methods included from Gitlab::SetupHelper

create_configuration, generate_configuration

Class Method Details

.configuration_toml(gitaly_dir, _storage_paths, options) ⇒ Object



151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# File 'lib/gitlab/setup_helper.rb', line 151

def configuration_toml(gitaly_dir, _storage_paths, options)
  raise 'This configuration is only intended for test' unless Rails.env.test?

  nodes = [{ storage: 'default', address: "unix:#{gitaly_dir}/gitaly.socket", primary: true, token: 'secret' }]
  second_storage_nodes = [{ storage: 'test_second_storage', address: "unix:#{gitaly_dir}/gitaly2.socket", primary: true, token: 'secret' }]

  storages = [{ name: 'default', node: nodes }, { name: 'test_second_storage', node: second_storage_nodes }]

  config = {
    socket_path: "#{gitaly_dir}/praefect.socket",
    virtual_storage: storages,
    token: 'secret'
  }

  if options[:per_repository]
    failover = { enabled: true, election_strategy: 'per_repository' }
    database = { host: options.fetch(:pghost),
                 port: options.fetch(:pgport).to_i,
                 user: options.fetch(:pguser),
                 dbname: options.fetch(:dbname, 'praefect_test') }

    config.merge!(database: database,
                  failover: failover)
  else
    failover = { enabled: false, election_strategy: 'local' }

    config.merge!(
      i_understand_my_election_strategy_is_unsupported_and_will_be_removed_without_warning: true,
      memory_queue_enabled: true,
      failover: failover
    )
  end

  TomlRB.dump(config)
end