Registry / database / mysql-clusterfarm

mysql-clusterfarm

JSON →
library2.7.9jsnpmunverified

A Node.js MySQL driver branched from mysqljs/mysql (v2.7.9) to add clustering capabilities, allowing connection pooling across replicated masters and slaves with automatic failover and deadlock handling. It is pure JavaScript, MIT licensed, and targets Node >= 0.6. Unlike the original mysql package, it introduces PoolClusterFarm for multi-master and multi-slave replication management, scaling from 1 master to many. However, it is unmaintained since 2017 (last commit) and relies on outdated dependencies.

npm install mysql-clusterfarm
INSTALL
IMPORT
SIG · MYSQL-CLUSTERFARM
M
mysql-clusterfarm
databasejavascriptv2.7.9
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

mysql
import mysql from 'mysql-clusterfarm'
const mysql = require('mysql')
CommonJS only; no ESM support. Do not confuse with the 'mysql' package.
poolClusterFarm
const poolClusterFarm = mysql.createPoolClusterFarm()
const poolClusterFarm = require('mysql-clusterfarm').createPoolClusterFarm()
Call as a method of the default export; factory pattern.
createPool
const pool = mysql.createPool({...})
const pool = new mysql.Pool()
Same API as mysql package; createPool returns a Pool instance.

Demonstrates setting up a PoolClusterFarm with a master and slave, then executing a query.

const mysql = require('mysql-clusterfarm'); const poolClusterFarm = mysql.createPoolClusterFarm(); // Add masters and slaves poolClusterFarm.addMaster('MASTER0', { host: process.env.MYSQL_HOST ?? 'localhost', user: process.env.MYSQL_USER ?? 'root', password: process.env.MYSQL_PASS ?? '' }); poolClusterFarm.addSlave('SLAVE0', 'MASTER0', { host: process.env.MYSQL_SLAVE_HOST ?? 'localhost', user: process.env.MYSQL_USER ?? 'root', password: process.env.MYSQL_PASS ?? '' }); // Get a connection from the cluster poolClusterFarm.getConnection((err, connection) => { if (err) throw err; connection.query('SELECT 1 + 1 AS solution', (err, results) => { connection.release(); if (err) throw err; console.log(results[0].solution); }); });
Debug
Known issues
gotchaThe package is a fork of mysqljs/mysql. Do not mix imports between the two; they are separate.
fix
Always use 'mysql-clusterfarm' in require/import statements, not 'mysql'.
affects: >=0.0.0
deprecatedPackage is unmaintained since 2017. No security updates or Node.js version compatibility patches.
fix
Consider using mysql2 with connection pooling or a dedicated clustering library like 'mysql-replication'.
affects: >=2.0.0
gotchaDeadlock handling can cause unexpected transaction rollbacks if not properly configured.
fix
Review deadlock handling options in PoolClusterFarm and test under load.
affects: >=2.7.0
breakingBreaking change: The poolClusterFarm API changed from earlier versions; addMaster/addSlave now require explicit names.
fix
Always provide a unique name as first argument to addMaster/addSlave.
affects: >=2.0.0
Errors
Common errors & fixes
Error: Cannot find module 'mysql'
Missing mysql package dependency; mysql-clusterfarm expects mysql as a peer dependency or internal module.
fix
npm install mysql-clusterfarm (may need to install mysql separately: npm install mysql)
TypeError: poolClusterFarm.getConnection is not a function
Importing the module incorrectly, or using an older API where getConnection is not available.
fix
const mysql = require('mysql-clusterfarm'); const poolClusterFarm = mysql.createPoolClusterFarm();
ER_ACCESS_DENIED_ERROR: Access denied for user
Invalid credentials or missing privileges on MySQL server.
fix
Double-check user, password, and host in addMaster/addSlave options.
Upgrade
Version history
2.7.9latest on npm
Audit
Dependencies
mysqlrequiredFork of the mysql package; uses internal mysql protocol logic
Agent activity
5 hits · last 30 days
node
4
Resources
mysql-clusterfarm — npm install mysql-clusterfarm · libregistry