BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
15b7bc62
Commit
15b7bc62
authored
Feb 22, 2017
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'connection-pool-host' into 'master'
Allow setting of a custom connection pool host See merge request !9445
parents
475715f1
cf521c95
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
4 deletions
+24
-4
database.rb
lib/gitlab/database.rb
+6
-1
database_spec.rb
spec/lib/gitlab/database_spec.rb
+18
-3
No files found.
lib/gitlab/database.rb
View file @
15b7bc62
...
...
@@ -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
=
...
...
spec/lib/gitlab/database_spec.rb
View file @
15b7bc62
...
...
@@ -119,9 +119,24 @@ describe Gitlab::Database, lib: true do
it
'creates a new connection pool with specific pool size'
do
pool
=
described_class
.
create_connection_pool
(
5
)
expect
(
pool
)
.
to
be_kind_of
(
ActiveRecord
::
ConnectionAdapters
::
ConnectionPool
)
expect
(
pool
.
spec
.
config
[
:pool
]).
to
eq
(
5
)
begin
expect
(
pool
)
.
to
be_kind_of
(
ActiveRecord
::
ConnectionAdapters
::
ConnectionPool
)
expect
(
pool
.
spec
.
config
[
:pool
]).
to
eq
(
5
)
ensure
pool
.
disconnect!
end
end
it
'allows setting of a custom hostname'
do
pool
=
described_class
.
create_connection_pool
(
5
,
'127.0.0.1'
)
begin
expect
(
pool
.
spec
.
config
[
:host
]).
to
eq
(
'127.0.0.1'
)
ensure
pool
.
disconnect!
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment