diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2017-02-22 15:43:01 +0100 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2017-02-22 15:47:53 +0100 |
commit | cf521c95761540f273804d23a1150dbb0af4e63b (patch) | |
tree | 99fdbd856f706dd0422dabf096c0b67774a0f2a5 /lib | |
parent | 12ac140a119b6802ebdfc3c596264f7fc292d4df (diff) | |
download | gitlab-ce-cf521c95761540f273804d23a1150dbb0af4e63b.tar.gz |
Allow setting of a custom connection pool host
This allows you to set a custom host when calling
Gitlab::Database.create_connection_pool. This is necessary for load
balancing as in this case we want to inherit all settings except for the
hostname.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/database.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/gitlab/database.rb b/lib/gitlab/database.rb index a47d7e98a62..d160cadc2d0 100644 --- a/lib/gitlab/database.rb +++ b/lib/gitlab/database.rb @@ -79,11 +79,16 @@ module Gitlab end end - def self.create_connection_pool(pool_size) + # pool_size - The size of the DB pool. + # host - An optional host name to use instead of the default one. + def self.create_connection_pool(pool_size, host = nil) # See activerecord-4.2.7.1/lib/active_record/connection_adapters/connection_specification.rb env = Rails.env original_config = ActiveRecord::Base.configurations + env_config = original_config[env].merge('pool' => pool_size) + env_config['host'] = host if host + config = original_config.merge(env => env_config) spec = |