DB: remove shared stuff, add singleton
Add Config class
This commit is contained in:
@@ -24,17 +24,17 @@ class DB {
|
||||
protected DataSource m_ds;
|
||||
protected Connection m_conn;
|
||||
|
||||
shared this(DBSettings settings) {
|
||||
this(DBSettings settings) {
|
||||
this.m_settings = settings;
|
||||
}
|
||||
|
||||
static shared(DB) getDB(DBSettings settings) {
|
||||
static DB getDB(DBSettings settings) {
|
||||
switch (settings.connector) {
|
||||
case DBConnector.DB_PGSQL:
|
||||
import db.pgsql;
|
||||
|
||||
debugF!"DB type is PostgreSQL";
|
||||
return new shared PostgresDB(settings);
|
||||
return new PostgresDB(settings);
|
||||
|
||||
default:
|
||||
throw new Exception("DB not supported");
|
||||
|
||||
@@ -5,8 +5,10 @@ import db.db;
|
||||
import ddbc.core;
|
||||
import ddbc.common;
|
||||
|
||||
import slf4d;
|
||||
|
||||
class PostgresDB : DB {
|
||||
shared this(Args...)(auto ref Args args) {
|
||||
this(Args...)(auto ref Args args) {
|
||||
super(args);
|
||||
}
|
||||
|
||||
@@ -22,6 +24,8 @@ class PostgresDB : DB {
|
||||
params = PGSQLDriver.setUserAndPassword(username, password);
|
||||
}
|
||||
|
||||
debugF!"DB URL: %s"(url);
|
||||
|
||||
return new ConnectionPoolDataSourceImpl(driver, url, params);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user