diff --git a/src/config.lua b/src/config.lua index 78a7899..df4fba9 100644 --- a/src/config.lua +++ b/src/config.lua @@ -11,6 +11,7 @@ return { time_zone = "+8:00", -- UTC + 8 + REDIS_PREFIX = 'Auth:', -- 配置redis数据库连接 REDIS = { HOST = "127.0.0.1", -- redis host @@ -25,5 +26,10 @@ return { USERNAME = "postgres", PASSWORD = "1qaz2wsx", -- postgres password DATABASE = "postgres", + + CHARSET = 'utf8', + POOL_TIMEOUT = 1000, -- postgresql pool timeout + POOL_SIZE = 100, -- postgresql pool size + TIMEOUT = 1000, -- postgresql timeout } } \ No newline at end of file diff --git a/src/config/database.lua b/src/config/database.lua deleted file mode 100644 index 5288618..0000000 --- a/src/config/database.lua +++ /dev/null @@ -1,37 +0,0 @@ -local env = require('config') - -return { - redis_prefix = 'Auth:', - redis = { - host = env.REDIS.HOST, - port = env.REDIS.PORT, - password = env.REDIS.PASSWORD - }, - - postgres = { - host = env.POSTGRES.HOST, - port = env.POSTGRES.PORT, - user = env.POSTGRES.USERNAME, - password = env.POSTGRES.PASSWORD, - database = env.POSTGRES.DATABASE, - - write = { -- postgresql write database - host = env.POSTGRES.HOST, - port = env.POSTGRES.PORT, - user = env.POSTGRES.USERNAME, - password = env.POSTGRES.PASSWORD, - database = env.POSTGRES.DATABASE - }, - read = { -- postgresql read database - host = env.POSTGRES.HOST, - port = env.POSTGRES.PORT, - user = env.POSTGRES.USERNAME, - password = env.POSTGRES.PASSWORD, - database = env.POSTGRES.DATABASE - }, - charset = 'utf8', - pool_timeout = 1000, -- postgresql pool timeout - pool_size = 100, -- postgresql pool size - timeout = 1000, -- postgresql timeout - }, -} \ No newline at end of file diff --git a/src/share/model.lua b/src/share/model.lua index 213b8d0..77fb448 100644 --- a/src/share/model.lua +++ b/src/share/model.lua @@ -1,5 +1,5 @@ local Database = require('share.database') -local dbconf = require("config.database") +local conf = require("config") local helpers = require('share.helpers') local implode = helpers.implode @@ -12,28 +12,28 @@ local WRITE = 'WRITE' local READ = 'READ' local database_write = Database:new({ - host = dbconf.postgres.write.host, - port = dbconf.postgres.write.port, - user = dbconf.postgres.write.user, - password = dbconf.postgres.write.password, - database = dbconf.postgres.write.database, - --charset = dbconf.postgres.charset, - --timeout = dbconf.postgres.timeout, - db_pool_timeout = dbconf.postgres.pool_timeout, - db_pool_size = dbconf.postgres.pool_size, + host = conf.POSTGRES.host, + port = conf.POSTGRES.port, + user = conf.POSTGRES.user, + password = conf.POSTGRES.password, + database = conf.POSTGRES.database, + --charset = conf.POSTGRES.charset, + --timeout = conf.POSTGRES.timeout, + db_pool_timeout = conf.POSTGRES.pool_timeout, + db_pool_size = conf.POSTGRES.pool_size, db_type = WRITE }) local database_read = Database:new({ - host = dbconf.postgres.read.host, - port = dbconf.postgres.read.port, - user = dbconf.postgres.read.user, - password = dbconf.postgres.read.password, - database = dbconf.postgres.read.database, - --charset = dbconf.postgres.charset, - --timeout = dbconf.postgres.timeout, - db_pool_timeout = dbconf.postgres.pool_timeout, - db_pool_size = dbconf.postgres.pool_size, + host = conf.POSTGRES.host, + port = conf.POSTGRES.port, + user = conf.POSTGRES.user, + password = conf.POSTGRES.password, + database = conf.POSTGRES.database, + --charset = conf.POSTGRES.charset, + --timeout = conf.POSTGRES.timeout, + db_pool_timeout = conf.POSTGRES.pool_timeout, + db_pool_size = conf.POSTGRES.pool_size, db_type = READ })