Skip to content

Add PoolCluster Feature. #522

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 27, 2013
Merged

Add PoolCluster Feature. #522

merged 1 commit into from
Jun 27, 2013

Conversation

ifsnow
Copy link
Contributor

@ifsnow ifsnow commented Jun 22, 2013

It's a feature related to #506

  1. support for multiple hosts connection.
  2. connection group & retry & selector (round-robin, random, order)
// create
var poolCluster = mysql.createPoolCluster();

poolCluster.add(config); // anonymous group
poolCluster.add('MASTER', masterConfig);
poolCluster.add('SLAVE1', slave1Config);
poolCluster.add('SLAVE2', slave2Config);

// Target Group : ALL(4 group), Selector : round-robin(default)
poolCluster.getConnection(function (err, connection) {});

// Target Group : MASTER, Selector : round-robin
poolCluster.getConnection('MASTER', function (err, connection) {});

// Target Group : SLAVE1-2(wild), Selector : order
// If can't connect to SLAVE1, return SLAVE2. (remove SLAVE1 in the cluster)
poolCluster.on('remove', function (nodeId) {
  console.log('REMOVED NODE : ' + nodeId); // nodeId = SLAVE1 
});

poolCluster.getConnection('SLAVE*', 'ORDER', function (err, connection) {});

// of namespace
poolCluster.of('*').getConnection(function (err, connection) {});

var pool = poolCluster.of('SLAVE*', 'RANDOM')
pool.getConnection(function (err, connection) {});
pool.getConnection(function (err, connection) {});

// destroy
poolCluster.end();

@felixge
Copy link
Collaborator

felixge commented Jun 22, 2013

💖 thanks! LGTM / makes sense.

About the test: Not a huge fan of adding an ad-hoc framework / test runner in the test directly. Feels like it's not entirely needed. That being said, if you want to simplify this / or use an existing testing lib (add as devDependency), go ahead.

@dresende @NateLillich any comments?

@ifsnow
Copy link
Contributor Author

ifsnow commented Jun 22, 2013

I have deleted an ad-hoc framework. :)

@dresende
Copy link
Collaborator

I like the idea, the code looks good. I can test it and improve (if needed) later on. I agree with @felixge about the ad-hoc framework for testing.

@felixge
Copy link
Collaborator

felixge commented Jun 25, 2013

LGTM now, feel free to merge unless anybody objects.

ifsnow added a commit that referenced this pull request Jun 27, 2013
@ifsnow ifsnow merged commit e2a3113 into mysqljs:master Jun 27, 2013
dveeden pushed a commit to dveeden/mysql that referenced this pull request Jan 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants