Commit 45d5e7d8 authored by Ira Snyder's avatar Ira Snyder Committed by Luc Didry

Allow users to configure maximum number of database connections

For both the MySQL and PostgreSQL database backends, allow the user to
configure the maximum number of concurrent database connections.

This is useful in environments where a very limited number of database
connections are available. This is also useful in environments with
strict policies against persistent database connections. In this case,
max_connections can be set to 0, which disables persistent database
connections completely.
parent cb8e8bdd
......@@ -12,3 +12,4 @@
* Phyks (Lucas Verney)
* Pierre Rudloff
* Belvar (Gwenn M) (breton translation)
* Ira W. Snyder
......@@ -53,6 +53,7 @@ sub _pg {
state $pg = Mojo::Pg->new($addr);
$pg->password($c->config->{pgdb}->{pwd});
$pg->username($c->config->{pgdb}->{user});
$pg->max_connections($c->config->{pgdb}->{max_connections}) if defined $c->config->{pgdb}->{max_connections};
return $pg;
}
......@@ -66,6 +67,7 @@ sub _mysql {
state $mysql = Mojo::mysql->new($addr);
$mysql->password($c->config->{mysqldb}->{pwd});
$mysql->username($c->config->{mysqldb}->{user});
$mysql->max_connections($c->config->{mysqldb}->{max_connections}) if defined $c->config->{mysqldb}->{max_connections};
return $mysql;
}
......
......@@ -84,8 +84,12 @@
#pgdb => {
# database => 'lstu',
# host => 'localhost',
# # optional, default is 5432
# #port => 5432,
# #user => 'DBUSER',
# #pwd => 'DBPASSWORD'
# #pwd => 'DBPASSWORD',
# # optional, default is 1
# #max_connections => 1,
#},
# MySQL ONLY - only used if dbtype is set to mysql
......@@ -94,8 +98,12 @@
#mysqldb => {
# database => 'lstu',
# host => 'localhost',
# # optional, default is 3306
# #port => 3306,
# #user => 'DBUSER',
# #pwd => 'DBPASSWORD'
# #pwd => 'DBPASSWORD',
# # optional, default is 5 (set to 0 to disable persistent connections)
# #max_connections => 5,
#},
# Rate-limiting for the API
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment