Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2017-02-22 17:43:01 +0300
committerYorick Peterse <yorickpeterse@gmail.com>2017-02-22 17:47:53 +0300
commitcf521c95761540f273804d23a1150dbb0af4e63b (patch)
tree99fdbd856f706dd0422dabf096c0b67774a0f2a5 /lib
parent12ac140a119b6802ebdfc3c596264f7fc292d4df (diff)
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.rb7
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 =