rascal 14.4.3 → 14.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/lib/amqp/Publication.js +41 -12
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/lib/amqp/Publication.js
CHANGED
|
@@ -169,6 +169,7 @@ function addListeners(channel, errorHandler, returnHandler) {
|
|
|
169
169
|
}
|
|
170
170
|
|
|
171
171
|
function removeListeners(channel, errorHandler, returnHandler) {
|
|
172
|
+
channel.removeAllListeners('drain');
|
|
172
173
|
channel.removeListener('error', errorHandler);
|
|
173
174
|
channel.removeListener('return', returnHandler);
|
|
174
175
|
channel.connection.removeListener('error', errorHandler);
|
|
@@ -177,37 +178,65 @@ function removeListeners(channel, errorHandler, returnHandler) {
|
|
|
177
178
|
|
|
178
179
|
function publishToExchange(channel, content, config, next) {
|
|
179
180
|
debug('Publishing %d bytes to exchange: %s with routingKeys: %s', content.length, config.exchange, _.compact([].concat(config.routingKey, config.options.CC, config.options.BCC)).join(', '));
|
|
180
|
-
|
|
181
|
-
|
|
181
|
+
|
|
182
|
+
const fn = () => {
|
|
183
|
+
return channel.publish(config.destination, config.routingKey, content, config.options);
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
publishNoConfirm(fn, channel, next);
|
|
182
187
|
}
|
|
183
188
|
|
|
184
189
|
function publishToConfirmExchange(channel, content, config, next) {
|
|
185
190
|
debug('Publishing %d bytes to confirm exchange: %s with routingKeys: %s', content.length, config.exchange, _.compact([].concat(config.routingKey, config.options.CC, config.options.BCC)).join(', '));
|
|
186
191
|
|
|
187
|
-
const
|
|
188
|
-
|
|
192
|
+
const fn = (cb) => {
|
|
193
|
+
return channel.publish(config.destination, config.routingKey, content, config.options, cb);
|
|
194
|
+
};
|
|
189
195
|
|
|
190
|
-
|
|
191
|
-
clearTimeout(timeout);
|
|
192
|
-
once(err, ok);
|
|
193
|
-
});
|
|
196
|
+
publishAndConfirm(fn, channel, config, next);
|
|
194
197
|
}
|
|
195
198
|
|
|
196
199
|
function sendToQueue(channel, content, config, next) {
|
|
197
200
|
debug('Publishing %d bytes to queue: %s', content.length, config.queue);
|
|
198
|
-
|
|
199
|
-
|
|
201
|
+
|
|
202
|
+
const fn = () => {
|
|
203
|
+
return channel.sendToQueue(config.destination, content, config.options);
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
publishNoConfirm(fn, channel, next);
|
|
200
207
|
}
|
|
201
208
|
|
|
202
209
|
function sendToConfirmQueue(channel, content, config, next) {
|
|
203
210
|
debug('Publishing %d bytes to queue: %s', content.length, config.queue);
|
|
204
211
|
|
|
212
|
+
const fn = (cb) => {
|
|
213
|
+
return channel.sendToQueue(config.destination, content, config.options, cb);
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
publishAndConfirm(fn, channel, config, next);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function publishNoConfirm(fn, channel, next) {
|
|
220
|
+
let drained = false;
|
|
221
|
+
channel.once('drain', () => {
|
|
222
|
+
drained = true;
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
const ok = fn();
|
|
226
|
+
next(null, ok || drained);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function publishAndConfirm(fn, channel, config, next) {
|
|
205
230
|
const once = _.once(next);
|
|
206
231
|
const timeout = config.timeout ? setConfirmationTimeout(config.timeout, config.destination, once) : null;
|
|
232
|
+
let drained = false;
|
|
233
|
+
channel.once('drain', () => {
|
|
234
|
+
drained = true;
|
|
235
|
+
});
|
|
207
236
|
|
|
208
|
-
const ok =
|
|
237
|
+
const ok = fn((err) => {
|
|
209
238
|
clearTimeout(timeout);
|
|
210
|
-
next(err, ok);
|
|
239
|
+
next(err, ok || drained);
|
|
211
240
|
});
|
|
212
241
|
}
|
|
213
242
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rascal",
|
|
3
|
-
"version": "14.4.
|
|
3
|
+
"version": "14.4.4",
|
|
4
4
|
"description": "A config driven wrapper for amqplib supporting multi-host connections, automatic error recovery, redelivery flood protection, transparent encryption / decryption, channel pooling and publication timeouts",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"dependencies": {
|