fix: retimer reschedule does not work as interval (#710)

* fix: retimer reschedule does not work as interval

* chore: apply suggestions from code review

Co-authored-by: Jacob Heun <jacobheun@gmail.com>

Co-authored-by: Jacob Heun <jacobheun@gmail.com>
This commit is contained in:
Vasco Santos
2020-07-14 19:11:29 +02:00
committed by GitHub
parent 99ff361a55
commit 999c1b7740
2 changed files with 4 additions and 16 deletions

View File

@ -178,7 +178,7 @@ class ConnectionManager extends EventEmitter {
const total = received + sent
this._checkMaxLimit('maxData', total)
log('metrics update', total)
this._timer.reschedule(this._options.pollInterval)
this._timer = retimer(this._checkMetrics, this._options.pollInterval)
}
/**
@ -291,17 +291,9 @@ class ConnectionManager extends EventEmitter {
async _autoDial () {
const minConnections = this._options.minConnections
const recursiveTimeoutTrigger = () => {
if (this._autoDialTimeout) {
this._autoDialTimeout.reschedule(this._options.autoDialInterval)
} else {
this._autoDialTimeout = retimer(this._autoDial, this._options.autoDialInterval)
}
}
// Already has enough connections
if (this.size >= minConnections) {
recursiveTimeoutTrigger()
this._autoDialTimeout = retimer(this._autoDial, this._options.autoDialInterval)
return
}
@ -332,7 +324,7 @@ class ConnectionManager extends EventEmitter {
}
}
recursiveTimeoutTrigger()
this._autoDialTimeout = retimer(this._autoDial, this._options.autoDialInterval)
}
/**