Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module.exports.pool = pool = mysql.createPoolCluster {
- restoreNodeTimeout: 5000
- }
- pool.add 'master', {
- host: config.get 'mysql.master.host'
- user: config.get 'mysql.master.id'
- password: config.get 'mysql.master.password'
- database: config.get 'mysql.master.scheme'
- debug: DEBUG
- acquireTimeout: 2000
- waitForConnections: true
- connectionLimit: if PROD then 80 else 20
- queueLimit: 0
- timezone: 'Asia/Seoul'
- }
- pool.add 'slave', {
- host: config.get 'mysql.slave.host'
- user: config.get 'mysql.slave.id'
- password: config.get 'mysql.slave.password'
- database: config.get 'mysql.slave.scheme'
- debug: DEBUG
- acquireTimeout: 2000
- waitForConnections: true
- connectionLimit: if PROD then 30 else 20
- queueLimit: 0
- timezone: 'Asia/Seoul'
- }
- pool.on 'enqueue', ->
- logger.warn 'Waiting for available connection slot. Make sure your connection is released.'
- module.exports.getConnection = (selector = 'master', pattern = 'RR') ->
- if selector is 'cache'
- return module.exports.getCacheConnection()
- else
- pool.of(selector, pattern).getConnectionAsync()
- .then (conn) ->
- return conn
- .disposer (db, promise) ->
- db.release()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement