Upgrade generic-pool to ~2.0.2
This commit is contained in:
parent
5fa19a0515
commit
6c0d7813f6
@ -37,15 +37,15 @@ module.exports = (function() {
|
|||||||
Step(
|
Step(
|
||||||
function() {
|
function() {
|
||||||
var step = this;
|
var step = this;
|
||||||
RedisPool.acquire(db, function(_redisClient) {
|
RedisPool.acquire(db, function(err, _redisClient) {
|
||||||
|
if ( err ) { step(err); return };
|
||||||
redisClient = _redisClient;
|
redisClient = _redisClient;
|
||||||
redisArgs.push(step);
|
redisArgs.push(step);
|
||||||
redisClient[redisFunc.toUpperCase()].apply(redisClient, redisArgs);
|
redisClient[redisFunc.toUpperCase()].apply(redisClient, redisArgs);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
function releaseRedisClient(err, data) {
|
function releaseRedisClient(err, data) {
|
||||||
if (err) throw err;
|
if ( redisClient ) RedisPool.release(db, redisClient);
|
||||||
RedisPool.release(db, redisClient);
|
|
||||||
callback(err, data);
|
callback(err, data);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -59,13 +59,13 @@ module.exports = function() {
|
|||||||
function getRedisClient() {
|
function getRedisClient() {
|
||||||
RedisPool.acquire(that.metadata_database, this);
|
RedisPool.acquire(that.metadata_database, this);
|
||||||
},
|
},
|
||||||
function lookupMetadata(data) {
|
function lookupMetadata(err, data) {
|
||||||
|
if (err) throw err;
|
||||||
redisClient = data;
|
redisClient = data;
|
||||||
redisClient.HGET(redisKey, hashKey, this);
|
redisClient.HGET(redisKey, hashKey, this);
|
||||||
},
|
},
|
||||||
function releaseRedisClient(err, data) {
|
function releaseRedisClient(err, data) {
|
||||||
if (err) throw err;
|
if ( redisClient ) RedisPool.release(that.metadata_database, redisClient);
|
||||||
RedisPool.release(that.metadata_database, redisClient);
|
|
||||||
callback(err, data);
|
callback(err, data);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -130,11 +130,12 @@ var oAuth = function(){
|
|||||||
|
|
||||||
me.getOAuthHash = function(access_key, callback){
|
me.getOAuthHash = function(access_key, callback){
|
||||||
var that = this;
|
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;
|
var redisClient = client;
|
||||||
redisClient.HGETALL(_.template(that.oauth_user_key, {oauth_access_key: access_key}), function(err, data){
|
redisClient.HGETALL(_.template(that.oauth_user_key, {oauth_access_key: access_key}), function(err, data){
|
||||||
RedisPool.release(that.oauth_database, redisClient);
|
RedisPool.release(that.oauth_database, redisClient);
|
||||||
return callback(err, data)
|
callback(err, data);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -11,8 +11,8 @@ var RedisPool = {
|
|||||||
if (!this.pools[database]) {
|
if (!this.pools[database]) {
|
||||||
this.pools[database] = this.makePool(database);
|
this.pools[database] = this.makePool(database);
|
||||||
}
|
}
|
||||||
this.pools[database].acquire(function(resource) {
|
this.pools[database].acquire(function(err, resource) {
|
||||||
callback(resource);
|
callback(err, resource);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
9
npm-shrinkwrap.json
generated
9
npm-shrinkwrap.json
generated
@ -186,15 +186,10 @@
|
|||||||
},
|
},
|
||||||
"pg": {
|
"pg": {
|
||||||
"version": "0.12.3-cdb1",
|
"version": "0.12.3-cdb1",
|
||||||
"from": "git://github.com/CartoDB/node-postgres.git#cdb_production",
|
"from": "git://github.com/CartoDB/node-postgres.git#cdb_production"
|
||||||
"dependencies": {
|
|
||||||
"generic-pool": {
|
|
||||||
"version": "2.0.2"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"generic-pool": {
|
"generic-pool": {
|
||||||
"version": "1.0.12"
|
"version": "2.0.3"
|
||||||
},
|
},
|
||||||
"redis": {
|
"redis": {
|
||||||
"version": "0.7.1"
|
"version": "0.7.1"
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
"underscore.string": "1.1.5",
|
"underscore.string": "1.1.5",
|
||||||
"pg": "git://github.com/CartoDB/node-postgres.git#cdb_production",
|
"pg": "git://github.com/CartoDB/node-postgres.git#cdb_production",
|
||||||
"express": "~2.5.11",
|
"express": "~2.5.11",
|
||||||
"generic-pool": "1.0.x",
|
"generic-pool": "~2.0.2",
|
||||||
"redis": "0.7.1",
|
"redis": "0.7.1",
|
||||||
"hiredis": "*",
|
"hiredis": "*",
|
||||||
"step": "0.0.x",
|
"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){
|
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.set("key","value");
|
||||||
client.get("key", function(err,data){
|
client.get("key", function(err,data){
|
||||||
assert.equal(data, "value");
|
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){
|
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.set("key","value");
|
||||||
client.get("key", function(err,data){
|
client.get("key", function(err,data){
|
||||||
assert.equal(data, "value");
|
assert.equal(data, "value");
|
||||||
redis_pool.release("MYDATABASE", client);
|
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){
|
client.get("key", function(err,data){
|
||||||
assert.equal(data, "value");
|
assert.equal(data, "value");
|
||||||
redis_pool.release("MYDATABASE", client);
|
redis_pool.release("MYDATABASE", client);
|
||||||
|
Loading…
Reference in New Issue
Block a user