off-sqs-debearloper
Advanced tools
Comparing version 0.1.7 to 0.1.8
var AWS = require('aws-sdk'), | ||
config = require('./config'), | ||
sqs = {}, | ||
when = require('when'); | ||
module.exports = listQueues = function (queueName){ | ||
@@ -10,3 +10,6 @@ var deferred = when.defer(); | ||
if(config.env.production || config.env.qa){ | ||
return listSQSQueues(queueName); }; | ||
AWS.config.update(config.awsConfigFile); | ||
sqs = new AWS.SQS(); | ||
return listSQSQueues(queueName); | ||
}; | ||
@@ -18,4 +21,2 @@ return listRabbitQueues(queueName); | ||
var deferred = when.defer(); | ||
AWS.config.update(config.awsConfigFile); | ||
var sqs = new AWS.SQS(); | ||
@@ -54,1 +55,60 @@ sqs.listQueues(function(err, res){ | ||
} | ||
function listQueues(_queueName){ | ||
var deferred = when.defer(); | ||
sqs.listQueues(function(err, res){ | ||
var queueFinder = false; | ||
if(res.QueueUrls) | ||
for(var i in res.QueueUrls) | ||
if(res.QueueUrls[i].split('/').pop() === _queueName) | ||
queueFinder = true; | ||
if(queueFinder){ | ||
getQueue(_queueName).then(function(queueUrl){ | ||
deferred.resolve(queueUrl); | ||
}); | ||
} else { | ||
createQueue(_queueName).then(function(){ | ||
getQueue(_queueName).then(function(queueUrl){ | ||
deferred.resolve(queueUrl); | ||
}) | ||
}); | ||
}; | ||
}); | ||
return deferred.promise; | ||
}; | ||
function getQueue(_queueName){ | ||
var deferred = when.defer(); | ||
sqs.getQueueUrl({QueueName: _queueName}, function(err, data){ | ||
if(err){ | ||
console.log("/63, " + err); | ||
} else{ | ||
console.log("By using the SQS queue: " + data.QueueUrl); | ||
deferred.resolve(data.QueueUrl); | ||
} | ||
}); | ||
return deferred.promise; | ||
}; | ||
function createQueue(_queueName){ | ||
var deferred = when.defer(); | ||
var cqParams = { | ||
QueueName: _queueName, | ||
Attributes: {} | ||
}; | ||
console.log(typeof sqs); | ||
sqs.createQueue(cqParams, function(err, res){ | ||
if(err){ | ||
console.log("/67, " + err); | ||
// stop recursivity | ||
} else { | ||
deferred.resolve(); | ||
} | ||
}); | ||
return deferred.promise; | ||
}; |
{ | ||
"name": "off-sqs-debearloper", | ||
"description": "Helper app that manages SQS and RabbitMQ transactions", | ||
"version": "0.1.7", | ||
"version": "0.1.8", | ||
"repository": { | ||
@@ -6,0 +6,0 @@ "type": "git", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12465
286