mysql
mysql copied to clipboard
Does mysql.createPoolCluster() extend the features of mysql.createPool?
I have been using createPool to create a connection pool. Now I want to use createPoolClusters.
As far as I know, both of them accepts the pool config object, which would be as follows.
{
connectionLimit : 10,
host : 'example.org',
user : 'bob',
password : 'secret',
database : 'my_db'
}
But the on('acquire'), on('connection'), on('enqueue'), on('release') events don't work anymore.
This is how my DB module looks right now.
const mysql = require('mysql')
const Log = require('../log')
const clusters = require('./clusters.json')
const poolCluster = mysql.createPoolCluster()
for(const cluster of clusters) {
cluster.config.connectionLimit = 20
poolCluster.add(cluster.name, cluster.config)
}
poolCluster.on('release', function (connection) {
Log.debug(`Connection ID ${connection.threadId} released`)
})
poolCluster.on('connection', function (connection) {
Log.debug(`Connection ID ${connection.threadId} connected`)
})
poolCluster.on('acquire', function (connection) {
Log.debug(`Connection ID ${connection.threadId} acquired`)
})
poolCluster.on('enqueue', function () {
Log.debug('Waiting for available connection slot')
})
poolCluster.on('error', function (err) {
Log.error(`Database Error ${err.code}`)
})
module.exports = poolCluster
is "debug" mode also missing in pool cluster? I cannot seem to find a way to enable it
@danySam does pool connection is actually used because in my case it will use single connection for doing all the operation.....