Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

amqp-wrapper

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

amqp-wrapper - npm Package Compare versions

Comparing version 5.1.0 to 5.2.0

test/configRKArray.js

36

lib/queue-setup.js

@@ -6,2 +6,20 @@ 'use strict';

function bindRoutingKeys(channel, exchange, queueName, keys, done) {
var routingKeys;
if (typeof keys === 'string') {
routingKeys = [keys];
} else {
routingKeys = keys;
}
if (routingKeys) {
async.map(routingKeys,
function(key, callback) {
channel.bindQueue(queueName, exchange, key, {}, callback);
},
done);
} else {
done();
}
}
function maybeDeclareDeadLetters(channel, queue, callback) {

@@ -18,6 +36,4 @@ if (!queue.options || !queue.options.deadLetterExchange) {

channel.assertQueue.bind(channel, qName, {}),
channel.bindQueue.bind(channel, qName,
queue.options.deadLetterExchange,
queue.options.deadLetterExchangeRoutingKey || queue.routingKey,
{}),
bindRoutingKeys.bind(undefined, channel, queue.options.deadLetterExchange, qName,
queue.options.deadLetterExchangeRoutingKey || queue.routingKey)
], callback);

@@ -33,13 +49,9 @@ }

debug('setupForConsume()', queue);
console.log('queue');
console.log(queue);
async.series([
maybeDeclareDeadLetters.bind(undefined, channel, queue),
channel.assertQueue.bind(channel, queue.name, queue.options),
function(callback) {
if (queue.routingKey) {
channel.bindQueue(queue.name, params.exchange, queue.routingKey, {},
callback);
} else {
callback();
}
}
bindRoutingKeys.bind(undefined, channel, params.exchange, queue.name,
queue.routingKey)
], callback);

@@ -46,0 +58,0 @@ };

{
"name": "amqp-wrapper",
"version": "5.1.0",
"version": "5.2.0",
"description": "A wrapper around https://github.com/squaremo/amqp.node to make consuming and publishing dead easy.",

@@ -5,0 +5,0 @@ "main": "amqp.js",

@@ -35,3 +35,5 @@ amqp-wrapper

name: process.env.AMQP_CONSUME,
routingKey: process.env.AMQP_ROUTING_KEY, // If supplied, queue is bound to this key on the exchange.
routingKey: process.env.AMQP_ROUTING_KEY, // If supplied, queue is bound to
// this key (or keys) on the exchange. NB Can be an array of string or just
// a string.
options: {/* ... */} // options passed to ch.assertQueue() in wrapped lib.

@@ -38,0 +40,0 @@ },

@@ -10,2 +10,3 @@ 'use strict';

var config = require('../config');
var configRKArray = require('../configRKArray');
describe('#constructor', function() {

@@ -68,2 +69,25 @@ it('should throw with empty constructor', function(done) {

});
it('allows you to specify an array for routingKey and binds each given',
function(done) {
var amqpLibMock = require('./amqplibmock')();
var mockedAMQP = SandboxedModule.require('../../amqp', {
requires: {
'amqplib/callback_api': amqpLibMock.mock
}
})(configRKArray);
mockedAMQP.connect(function(err) {
if (err) {
return done(err);
}
// one queue, dead lettered
expect(amqpLibMock.assertQueueSpy.callCount).to.equal(2);
// Bind the consume queue with its two routing keys, and its dead
// letter queue.
expect(amqpLibMock.bindQueueSpy.callCount).to.equal(4);
done();
});
});
it('should just declare if you don\'t specify routing key', function(done) {

@@ -70,0 +94,0 @@ var amqpLibMock = require('./amqplibmock')();

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc