committed by
delvedor
parent
10c6038003
commit
a731fda729
@ -34,11 +34,7 @@ class ConnectionPool {
|
||||
this._ssl = opts.ssl
|
||||
this._agent = opts.agent
|
||||
// the resurrect timeout is 60s
|
||||
// we multiply it by 2 because the resurrect formula is
|
||||
// `Math.pow(resurrectTimeout * 2, deadCount -1)`
|
||||
// and we don't need to multiply by 2
|
||||
// the resurrectTimeout every time
|
||||
this.resurrectTimeout = 1000 * 60 * 2
|
||||
this.resurrectTimeout = 1000 * 60
|
||||
// number of consecutive failures after which
|
||||
// the timeout doesn't increase
|
||||
this.resurrectTimeoutCutoff = 5
|
||||
@ -94,15 +90,9 @@ class ConnectionPool {
|
||||
connection.status = Connection.statuses.DEAD
|
||||
connection.deadCount++
|
||||
// resurrectTimeout formula:
|
||||
// `Math.pow(resurrectTimeout * 2, deadCount -1)`
|
||||
// we don't need to multiply the resurrectTimeout by 2
|
||||
// every time, it is cached during the initialization
|
||||
connection.resurrectTimeout = Date.now() + Math.pow(
|
||||
this.resurrectTimeout,
|
||||
Math.min(
|
||||
connection.deadCount - 1,
|
||||
this.resurrectTimeoutCutoff
|
||||
)
|
||||
// `resurrectTimeout * 2 ** min(deadCount - 1, resurrectTimeoutCutoff)`
|
||||
connection.resurrectTimeout = Date.now() + this.resurrectTimeout * Math.pow(
|
||||
2, Math.min(connection.deadCount - 1, this.resurrectTimeoutCutoff)
|
||||
)
|
||||
|
||||
// sort the dead list in ascending order
|
||||
|
||||
Reference in New Issue
Block a user