Skip to content

Commit

Permalink
fix(link-options): changes based on review
Browse files Browse the repository at this point in the history
  • Loading branch information
mbroadst committed Aug 12, 2015
1 parent a04629c commit d547ef4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
24 changes: 12 additions & 12 deletions lib/amqp_client.js
Expand Up @@ -172,27 +172,27 @@ AMQPClient.prototype.connect = function(url) {
* Creates a sender link for the given address, with optional link policy
*
* @method createSender
* @param {String} [address] An address to connect this link to
* @param {Object} [options] Policy used for creating the sender link
* @param {String} address An address to connect this link to. If not provided will use default queue from connection uri.
* @param {Object} [policyOverrides] Policy overrides used for creating this sender link
*
* @return {Promise}
*/
AMQPClient.prototype.createSender = function(address, options) {
AMQPClient.prototype.createSender = function(address, policyOverrides) {
if (!this._connection) {
throw new Error('Must connect before creating links');
}

address = u.parseLinkAddress(address || this._defaultQueue, this.policy);
options = options || {};
policyOverrides = policyOverrides || {};

var linkName = u.linkName(address.name, options),
var linkName = u.linkName(address.name, policyOverrides),
linkPolicy = u.deepMerge({
options: {
name: linkName,
source: { address: 'localhost' },
target: { address: address.name }
}
}, options, this.policy.senderLink);
}, policyOverrides, this.policy.senderLink);

if (!!address.subject && this.policy.defaultSubjects) {
linkPolicy.defaultSubject = address.subject;
Expand Down Expand Up @@ -220,27 +220,27 @@ AMQPClient.prototype.createSender = function(address, options) {
* used to listen for 'message' events.
*
* @method createReceiver
* @param {String} [source] Source of the link to connect to. If not provided will use default queue from connection uri.
* @param {Object} [options] Link policy used for creating this receiver link
* @param {String} address An address to connect this link to. If not provided will use default queue from connection uri.
* @param {Object} [policyOverrides] Policy overrides used for creating this receiver link
*
* @return {Promise}
*/
AMQPClient.prototype.createReceiver = function(address, options) {
AMQPClient.prototype.createReceiver = function(address, policyOverrides) {
if (!this._connection) {
throw new Error('Must connect before creating links');
}

address = u.parseLinkAddress(address || this._defaultQueue, this.policy);
options = options || {};
policyOverrides = policyOverrides || {};

var linkName = u.linkName(address.name, options),
var linkName = u.linkName(address.name, policyOverrides),
linkPolicy = u.deepMerge({
options: {
name: linkName,
source: { address: address.name },
target: { address: 'localhost' }
}
}, options, this.policy.receiverLink);
}, policyOverrides, this.policy.receiverLink);

// if a subject has been provided then automatically set up a filter to match
// on that subject.
Expand Down
12 changes: 6 additions & 6 deletions lib/utilities.js
Expand Up @@ -289,11 +289,11 @@ module.exports.dispositionRange = function(message) {
/**
* Generates a link name for a given address
*
* @param address link address
* @param options link creation policy
* @return String
* @param address link address
* @param [policyOverrides] link creation policy overrides
* @return {String}
*/
module.exports.linkName = function(address, policy) {
return ((!!policy && !!policy.options && !!policy.options.name) ?
policy.options.name : address + '_' + uuid.v4());
module.exports.linkName = function(address, policyOverrides) {
return ((!!policyOverrides && !!policyOverrides.name) ?
policyOverrides.name : address + '_' + uuid.v4());
};
12 changes: 6 additions & 6 deletions test/unit/test_amqpclient.js
Expand Up @@ -106,7 +106,7 @@ describe('AMQPClient', function() {

return client.connect(mock_uri)
.then(function () {
return client.createSender(queue, { options: { name: 'queue_TX' } });
return client.createSender(queue, { name: 'queue_TX' });
})
.then(function (sender) {
return Promise.all([
Expand Down Expand Up @@ -176,7 +176,7 @@ describe('AMQPClient', function() {

return client.connect(mock_uri)
.then(function () {
return client.createSender(queue, { options: { name: 'queue_TX' } });
return client.createSender(queue, { name: 'queue_TX' });
})
.then(function (sender) {
return Promise.all([
Expand Down Expand Up @@ -253,8 +253,8 @@ describe('AMQPClient', function() {
return client.connect(mock_uri)
.then(function() {
return Promise.all([
client.createReceiver('queue1', { options: { name: 'queue1_RX' } }),
client.createReceiver('queue2', { options: { name: 'queue2_RX' } })
client.createReceiver('queue1', { name: 'queue1_RX' }),
client.createReceiver('queue2', { name: 'queue2_RX' })
]);
})
.then(function() {
Expand Down Expand Up @@ -314,7 +314,7 @@ describe('AMQPClient', function() {

return client.connect(mock_uri)
.then(function() {
return client.createReceiver(queue, { options: { name: 'queue_RX' } });
return client.createReceiver(queue, { name: 'queue_RX' });
})
.then(function() {
process.nextTick(function() {
Expand Down Expand Up @@ -373,7 +373,7 @@ describe('AMQPClient', function() {

return client.connect(mock_uri)
.then(function() {
return client.createReceiver(queue, { options: { name: 'queue_RX' } });
return client.createReceiver(queue, { name: 'queue_RX' });
})
.then(function() {
process.nextTick(function() {
Expand Down

0 comments on commit d547ef4

Please sign in to comment.