Skip to content
This repository has been archived by the owner on Mar 10, 2020. It is now read-only.

Feature/bn forward callback function #185

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/abstract_ascoltatore.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ AbstractAscoltatore.prototype._setPublish = function() {
publish = this.publish;
} else {
publish = function (topic, payload, options, done) {
return f.call(this, topic, payload, done);
return f.call(this, topic, payload, options, done);
};
}

Expand Down
17 changes: 10 additions & 7 deletions lib/amqp_ascoltatore.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ var AbstractAscoltatore = require('./abstract_ascoltatore');
var steed = require("steed")();
var SubsCounter = require("./subs_counter");
var debug = require("debug")("ascoltatori:amqp");
var _ = require('lodash');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please avoid adding lodash as a dependency?


var defaultExchangeOptions = {
type: "topic",
confirm: true
};

/**
* The AMQPAscoltatore is a class that inherits from AbstractAscoltatore.
Expand Down Expand Up @@ -80,10 +86,8 @@ AMQPAscoltatore.prototype._startConn = function() {

function(callback) {
debug("connected");
that._exchange = conn.exchange(that._opts.exchange, {
type: "topic",
confirm: true
});
var exchangeOptions = _.assignIn({}, defaultExchangeOptions, that._opts.exchangeOptions || {});
that._exchange = conn.exchange(that._opts.exchange, exchangeOptions);
that._exchange.once("open", wrap(callback));
},

Expand Down Expand Up @@ -149,13 +153,12 @@ AMQPAscoltatore.prototype.subscribe = function subscribe(topic, callback, done)
debug("registered new subscriber for topic " + topic);
};

AMQPAscoltatore.prototype.publish = function publish(topic, message, done) {
AMQPAscoltatore.prototype.publish = function publish(topic, message, options, done) {
this._raiseIfClosed();

debug("new message published to " + topic);

this._exchange.publish(this._pubTopic(topic), String(message));
defer(done);
this._exchange.publish(this._pubTopic(topic), String(message), options, done);
};

AMQPAscoltatore.prototype.unsubscribe = function unsubscribe(topic, callback, done) {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
},
"dependencies": {
"debug": "^2.2.0",
"lodash": "^4.0.0",
"uuid": "^3.0.0",
"qlobber": "~0.7.0",
"steed": "^1.1.3"
Expand Down