Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Does mysql.createPoolCluster() extend the features of mysql.createPool? #2241

Copy link
Copy link
Open
@danySam

Description

@danySam
Issue body actions

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.