Last active
August 29, 2015 14:05
-
-
Save brigand/2c653c3a378a8d759b15 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mysql = require('mysql'), | |
http = require('http'); | |
var connections = [null, null, null].map(function(){ | |
var connection = mysql.createConnection({ | |
host : 'localhost', | |
database : 'benchmark', | |
user : 'root', | |
password : '1234' | |
}); | |
connection.connect(); | |
return connection; | |
}); | |
http.createServer(function(req, res){ | |
var state = { | |
foo: false, | |
bar: false, | |
baz: false | |
}; | |
var done = function( tbl ){ | |
state[ tbl ] = true; | |
if( state.foo && state.bar && state.baz ){ | |
res.end('OK'); | |
} | |
}; | |
connections[0].query('SELECT * FROM foo', function(err, rows, fields) { | |
done('foo'); | |
}); | |
connections[1].query('SELECT * FROM bar', function(err, rows, fields) { | |
done('bar'); | |
}); | |
connections[2].query('SELECT * FROM baz', function(err, rows, fields) { | |
done('baz'); | |
}); | |
}).listen(3000); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment