aboutsummaryrefslogtreecommitdiff
path: root/brep/database.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2016-03-19 15:10:50 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2016-03-19 19:58:33 +0300
commitf9d6c62ec593ec743a4ec9b25d7614606d27d4fa (patch)
tree1b00a70f0f74bc3d82d7190b20cf59fb355b0fa0 /brep/database.cxx
parent45aec70e4b577aaec17720b6082fe6b8ad0e243f (diff)
Use connection_pool_factory in brep module
Diffstat (limited to 'brep/database.cxx')
-rw-r--r--brep/database.cxx15
1 files changed, 10 insertions, 5 deletions
diff --git a/brep/database.cxx b/brep/database.cxx
index 1f70881..4b56c37 100644
--- a/brep/database.cxx
+++ b/brep/database.cxx
@@ -7,6 +7,7 @@
#include <map>
#include <odb/pgsql/database.hxx>
+#include <odb/pgsql/connection-factory.hxx>
namespace brep
{
@@ -26,11 +27,11 @@ namespace brep
}
}
- shared_ptr<odb::database>
+ using namespace odb;
+
+ shared_ptr<database>
shared_database (const options::db& o)
{
- using odb::pgsql::database;
-
static std::map<options::db, weak_ptr<database>> databases;
auto i (databases.find (o));
@@ -40,14 +41,18 @@ namespace brep
return d;
}
+ unique_ptr<pgsql::connection_factory>
+ f (new pgsql::connection_pool_factory (o.db_max_connections ()));
+
shared_ptr<database> d (
- make_shared<database> (
+ make_shared<pgsql::database> (
o.db_user (),
o.db_password (),
o.db_name (),
o.db_host (),
o.db_port (),
- "options='-c default_transaction_isolation=serializable'"));
+ "options='-c default_transaction_isolation=serializable'",
+ move (f)));
databases[o] = d;
return d;