amqp-wrapper
Advanced tools
Comparing version 5.2.0 to 5.3.0
28
amqp.js
'use strict'; | ||
var amqp = require('amqplib/callback_api'); | ||
var stringifysafe = require('json-stringify-safe'); | ||
var queueSetup = require('./lib/queue-setup'); | ||
var debug = require('debug')('amqp-wrapper'); | ||
var amqp = require('amqplib/callback_api'), | ||
stringifysafe = require('json-stringify-safe'), | ||
queueSetup = require('./lib/queue-setup'), | ||
debug = require('debug')('amqp-wrapper'), | ||
Deferred = require('deferential'); | ||
@@ -22,2 +23,3 @@ module.exports = function(config) { | ||
connect: function(cb) { | ||
var d = Deferred(); | ||
amqp.connect(config.url, createChannel); | ||
@@ -28,3 +30,3 @@ | ||
if (err) { | ||
return cb(err); | ||
return d.reject(err); | ||
} | ||
@@ -38,3 +40,3 @@ | ||
if (err) { | ||
return cb(err); | ||
return d.reject(err); | ||
} | ||
@@ -50,10 +52,11 @@ channel = ch; | ||
if (err) { | ||
return cb(err); | ||
return d.reject(err); | ||
} | ||
if (config.queue && config.queue.name) { | ||
queueSetup.setupForConsume(channel, config, cb); | ||
queueSetup.setupForConsume(channel, config, d.resolver(cb)); | ||
} else { | ||
cb(); | ||
d.resolve(); | ||
} | ||
} | ||
return d.nodeify(cb); | ||
}, | ||
@@ -69,4 +72,5 @@ | ||
*/ | ||
publish: function(routingKey, message, options, callback) { | ||
publish: function(routingKey, message, options, cb) { | ||
debug('publish()'); | ||
var d = Deferred(); | ||
if (typeof message === 'object') { | ||
@@ -76,3 +80,5 @@ message = stringifysafe(message); | ||
channel.publish(config.exchange, routingKey, new Buffer(message), | ||
options, callback); | ||
options, d.resolver(cb)); | ||
return d.nodeify(cb); | ||
}, | ||
@@ -79,0 +85,0 @@ |
{ | ||
"name": "amqp-wrapper", | ||
"version": "5.2.0", | ||
"version": "5.3.0", | ||
"description": "A wrapper around https://github.com/squaremo/amqp.node to make consuming and publishing dead easy.", | ||
"main": "amqp.js", | ||
"scripts": { | ||
"test": "istanbul cover _mocha -- test/lib", | ||
"test": "NODE_ENV=test mocha test --recursive", | ||
"jshint": "jshint -c .jshintrc --exclude-path .gitignore .", | ||
@@ -29,21 +29,15 @@ "codestyle": "jscs -p google lib/ test/" | ||
"debug": "^1.0.4", | ||
"json-stringify-safe": "^5.0.0" | ||
"deferential": "^1.0.0", | ||
"json-stringify-safe": "^5.0.0", | ||
"q": "^1.4.1" | ||
}, | ||
"devDependencies": { | ||
"exec-sync": "^0.1.6", | ||
"expect.js": "^0.3.1", | ||
"istanbul": "^0.3.2", | ||
"jscs": "^1.6.1", | ||
"jshint": "^2.5.5", | ||
"jshint": "^2.8.0", | ||
"lodash": "^2.4.1", | ||
"mocha": "^1.21.4", | ||
"pre-commit": "^0.0.9", | ||
"sandboxed-module": "^0.3.0", | ||
"sinon": "^1.10.3" | ||
}, | ||
"pre-commit": [ | ||
"jshint", | ||
"codestyle", | ||
"test" | ||
] | ||
} | ||
} |
@@ -84,3 +84,7 @@ amqp-wrapper | ||
# Promises | ||
`connect()` and `publish()` support promises too. If you don't give a callback, they'll return a promise! | ||
# License | ||
@@ -87,0 +91,0 @@ |
@@ -1,13 +0,27 @@ | ||
var execSync = require('exec-sync'); | ||
var response = execSync('boot2docker ip', true); | ||
var dockerhost = response.stderr ? 'localhost' : response.stdout; | ||
module.exports = { | ||
url: 'amqp://guest:guest@' + dockerhost, | ||
exchange: 'mytestexchange', | ||
queue: { | ||
name: 'myconsumequeue', | ||
routingKey: 'myRoutingQueue', | ||
options: {deadLetterExchange: 'wow'} | ||
good: { | ||
url: process.env.AMQP_URL || 'amqp://guest:guest@localhost', | ||
exchange: 'mytestexchange', | ||
queue: { | ||
name: 'myconsumequeue', | ||
routingKey: 'myRoutingQueue', | ||
options: {deadLetterExchange: 'wow'} | ||
} | ||
}, | ||
noRoutingKey: { | ||
url: process.env.AMQP_URL || 'amqp://guest:guest@localhost', | ||
exchange: 'hasone', | ||
queue: { | ||
name: 'myconsumequeue', | ||
options: {} | ||
} | ||
}, | ||
routingKeyArray: { | ||
url: process.env.AMQP_URL || 'amqp://guest:guest@localhost', | ||
exchange: 'mytestexchange', | ||
queue: { | ||
name: 'myconsumequeue', | ||
routingKey: ['myRoutingKey', 'myRoutingKey2'], | ||
options: {deadLetterExchange: 'wow'} | ||
} | ||
} | ||
@@ -14,0 +28,0 @@ }; |
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
19806
7
14
429
113
6
1
+ Addeddeferential@^1.0.0
+ Addedq@^1.4.1
+ Addeddeferential@1.0.0(transitive)
+ Addednative-promise-only@0.8.1(transitive)
+ Addedq@1.5.1(transitive)