Replace array by counter value in throttler
This commit is contained in:
parent
1e0ed7ee17
commit
936b7804de
@ -24,15 +24,15 @@ module.exports = class Throttler extends Transform {
|
||||
this.bytesPerSecondHistory.shift();
|
||||
}
|
||||
|
||||
const doesNotReachThreshold = [];
|
||||
let doesNotReachThreshold = 0;
|
||||
|
||||
for (const bytesPerSecond of this.bytesPerSecondHistory) {
|
||||
if (bytesPerSecond <= this.minimunBytesPerSecondThershold) {
|
||||
doesNotReachThreshold.push(true);
|
||||
doesNotReachThreshold += 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (doesNotReachThreshold.length >= this.sampleLength) {
|
||||
if (doesNotReachThreshold >= this.sampleLength) {
|
||||
clearInterval(this._interval);
|
||||
this.pgstream.emit('error', new Error('Connection closed by server: input data too slow'));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user