Alter client queue parameters and error reporting
- Use 'queueDisable' as option for disabling client RequestQueue - Throw more meaningful ConnectionError when enqueue fails
This commit is contained in:
parent
b49c2efed2
commit
9e2bbe1072
|
@ -202,12 +202,11 @@ function Client(options) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
this.queuing = (options.queuing !== undefined) ? options.queuing : true;
|
|
||||||
this.queue = new RequestQueue({
|
this.queue = new RequestQueue({
|
||||||
size: parseInt((options.queueSize || 0), 10),
|
size: parseInt((options.queueSize || 0), 10),
|
||||||
timeout: parseInt((options.queueTimeout || 0), 10)
|
timeout: parseInt((options.queueTimeout || 0), 10)
|
||||||
});
|
});
|
||||||
if (!this.queuing) {
|
if (options.queueDisable) {
|
||||||
this.queue.freeze();
|
this.queue.freeze();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1065,7 +1064,7 @@ Client.prototype._send = function _send(message,
|
||||||
}
|
}
|
||||||
if (!this.socket || !this.connected) {
|
if (!this.socket || !this.connected) {
|
||||||
if (!this.queue.enqueue(message, expect, emitter, callback)) {
|
if (!this.queue.enqueue(message, expect, emitter, callback)) {
|
||||||
callback(new Error('unable to enqueue request'));
|
callback(new ConnectionError('connection unavailable'));
|
||||||
}
|
}
|
||||||
// Initiate reconnect if needed
|
// Initiate reconnect if needed
|
||||||
if (this.reconnect) {
|
if (this.reconnect) {
|
||||||
|
|
Loading…
Reference in New Issue