Upgrade generic-pool to ~2.0.2
This commit is contained in:
parent
5fa19a0515
commit
6c0d7813f6
@ -37,15 +37,15 @@ module.exports = (function() {
|
||||
Step(
|
||||
function() {
|
||||
var step = this;
|
||||
RedisPool.acquire(db, function(_redisClient) {
|
||||
RedisPool.acquire(db, function(err, _redisClient) {
|
||||
if ( err ) { step(err); return };
|
||||
redisClient = _redisClient;
|
||||
redisArgs.push(step);
|
||||
redisClient[redisFunc.toUpperCase()].apply(redisClient, redisArgs);
|
||||
});
|
||||
},
|
||||
function releaseRedisClient(err, data) {
|
||||
if (err) throw err;
|
||||
RedisPool.release(db, redisClient);
|
||||
if ( redisClient ) RedisPool.release(db, redisClient);
|
||||
callback(err, data);
|
||||
}
|
||||
);
|
||||
|
@ -59,13 +59,13 @@ module.exports = function() {
|
||||
function getRedisClient() {
|
||||
RedisPool.acquire(that.metadata_database, this);
|
||||
},
|
||||
function lookupMetadata(data) {
|
||||
function lookupMetadata(err, data) {
|
||||
if (err) throw err;
|
||||
redisClient = data;
|
||||
redisClient.HGET(redisKey, hashKey, this);
|
||||
},
|
||||
function releaseRedisClient(err, data) {
|
||||
if (err) throw err;
|
||||
RedisPool.release(that.metadata_database, redisClient);
|
||||
if ( redisClient ) RedisPool.release(that.metadata_database, redisClient);
|
||||
callback(err, data);
|
||||
}
|
||||
);
|
||||
|
@ -130,11 +130,12 @@ var oAuth = function(){
|
||||
|
||||
me.getOAuthHash = function(access_key, callback){
|
||||
var that = this;
|
||||
RedisPool.acquire(this.oauth_database, function(client){
|
||||
RedisPool.acquire(this.oauth_database, function(err, client){
|
||||
if ( err ) { callback(err); return; }
|
||||
var redisClient = client;
|
||||
redisClient.HGETALL(_.template(that.oauth_user_key, {oauth_access_key: access_key}), function(err, data){
|
||||
RedisPool.release(that.oauth_database, redisClient);
|
||||
return callback(err, data)
|
||||
callback(err, data);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
@ -6,13 +6,13 @@ var RedisPool = {
|
||||
//
|
||||
// - `database` {String} redis database name
|
||||
// - `callback` {Function} callback to call once acquired. Takes the form
|
||||
// `callback(err, resource)`
|
||||
// `callback(err, resource)`
|
||||
acquire: function(database, callback) {
|
||||
if (!this.pools[database]) {
|
||||
this.pools[database] = this.makePool(database);
|
||||
}
|
||||
this.pools[database].acquire(function(resource) {
|
||||
callback(resource);
|
||||
this.pools[database].acquire(function(err, resource) {
|
||||
callback(err, resource);
|
||||
});
|
||||
},
|
||||
|
||||
@ -52,4 +52,4 @@ var RedisPool = {
|
||||
}
|
||||
|
||||
|
||||
module.exports = RedisPool;
|
||||
module.exports = RedisPool;
|
||||
|
9
npm-shrinkwrap.json
generated
9
npm-shrinkwrap.json
generated
@ -186,15 +186,10 @@
|
||||
},
|
||||
"pg": {
|
||||
"version": "0.12.3-cdb1",
|
||||
"from": "git://github.com/CartoDB/node-postgres.git#cdb_production",
|
||||
"dependencies": {
|
||||
"generic-pool": {
|
||||
"version": "2.0.2"
|
||||
}
|
||||
}
|
||||
"from": "git://github.com/CartoDB/node-postgres.git#cdb_production"
|
||||
},
|
||||
"generic-pool": {
|
||||
"version": "1.0.12"
|
||||
"version": "2.0.3"
|
||||
},
|
||||
"redis": {
|
||||
"version": "0.7.1"
|
||||
|
@ -15,7 +15,7 @@
|
||||
"underscore.string": "1.1.5",
|
||||
"pg": "git://github.com/CartoDB/node-postgres.git#cdb_production",
|
||||
"express": "~2.5.11",
|
||||
"generic-pool": "1.0.x",
|
||||
"generic-pool": "~2.0.2",
|
||||
"redis": "0.7.1",
|
||||
"hiredis": "*",
|
||||
"step": "0.0.x",
|
||||
|
@ -18,7 +18,8 @@ test('test pool object has an aquire function', function(){
|
||||
});
|
||||
|
||||
test('test calling aquire returns a redis client object that can get/set', function(done){
|
||||
redis_pool.acquire(0, function(client){
|
||||
redis_pool.acquire(0, function(err, client){
|
||||
assert.ok(!err);
|
||||
client.set("key","value");
|
||||
client.get("key", function(err,data){
|
||||
assert.equal(data, "value");
|
||||
@ -29,12 +30,14 @@ test('test calling aquire returns a redis client object that can get/set', funct
|
||||
});
|
||||
|
||||
test('test calling aquire on another DB returns a redis client object that can get/set', function(done){
|
||||
redis_pool.acquire("MYDATABASE", function(client){
|
||||
redis_pool.acquire("MYDATABASE", function(err, client){
|
||||
assert.ok(!err);
|
||||
client.set("key","value");
|
||||
client.get("key", function(err,data){
|
||||
assert.equal(data, "value");
|
||||
redis_pool.release("MYDATABASE", client);
|
||||
redis_pool.acquire("MYDATABASE", function(client){
|
||||
redis_pool.acquire("MYDATABASE", function(err, client){
|
||||
assert.ok(!err);
|
||||
client.get("key", function(err,data){
|
||||
assert.equal(data, "value");
|
||||
redis_pool.release("MYDATABASE", client);
|
||||
|
Loading…
Reference in New Issue
Block a user