committed by
delvedor
parent
9bb2d237e4
commit
ddb72d6e50
@ -34,11 +34,7 @@ class ConnectionPool {
|
|||||||
this._ssl = opts.ssl
|
this._ssl = opts.ssl
|
||||||
this._agent = opts.agent
|
this._agent = opts.agent
|
||||||
// the resurrect timeout is 60s
|
// the resurrect timeout is 60s
|
||||||
// we multiply it by 2 because the resurrect formula is
|
this.resurrectTimeout = 1000 * 60
|
||||||
// `Math.pow(resurrectTimeout * 2, deadCount -1)`
|
|
||||||
// and we don't need to multiply by 2
|
|
||||||
// the resurrectTimeout every time
|
|
||||||
this.resurrectTimeout = 1000 * 60 * 2
|
|
||||||
// number of consecutive failures after which
|
// number of consecutive failures after which
|
||||||
// the timeout doesn't increase
|
// the timeout doesn't increase
|
||||||
this.resurrectTimeoutCutoff = 5
|
this.resurrectTimeoutCutoff = 5
|
||||||
@ -94,15 +90,9 @@ class ConnectionPool {
|
|||||||
connection.status = Connection.statuses.DEAD
|
connection.status = Connection.statuses.DEAD
|
||||||
connection.deadCount++
|
connection.deadCount++
|
||||||
// resurrectTimeout formula:
|
// resurrectTimeout formula:
|
||||||
// `Math.pow(resurrectTimeout * 2, deadCount -1)`
|
// `resurrectTimeout * 2 ** min(deadCount - 1, resurrectTimeoutCutoff)`
|
||||||
// we don't need to multiply the resurrectTimeout by 2
|
connection.resurrectTimeout = Date.now() + this.resurrectTimeout * Math.pow(
|
||||||
// every time, it is cached during the initialization
|
2, Math.min(connection.deadCount - 1, this.resurrectTimeoutCutoff)
|
||||||
connection.resurrectTimeout = Date.now() + Math.pow(
|
|
||||||
this.resurrectTimeout,
|
|
||||||
Math.min(
|
|
||||||
connection.deadCount - 1,
|
|
||||||
this.resurrectTimeoutCutoff
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// sort the dead list in ascending order
|
// sort the dead list in ascending order
|
||||||
|
|||||||
@ -74,7 +74,7 @@ test('Should execute the recurrect API with the ping strategy', t => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
q.add((q, done) => {
|
q.add((q, done) => {
|
||||||
clock.tick(10)
|
clock.tick(1000 * 61)
|
||||||
client.info((err, result) => {
|
client.info((err, result) => {
|
||||||
t.error(err)
|
t.error(err)
|
||||||
done()
|
done()
|
||||||
@ -133,7 +133,7 @@ test('Resurrect a node and handle 502/3/4 status code', t => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
q.add((q, done) => {
|
q.add((q, done) => {
|
||||||
clock.tick(10)
|
clock.tick(1000 * 61)
|
||||||
client.info((err, result) => {
|
client.info((err, result) => {
|
||||||
t.error(err)
|
t.error(err)
|
||||||
done()
|
done()
|
||||||
@ -141,7 +141,7 @@ test('Resurrect a node and handle 502/3/4 status code', t => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
q.add((q, done) => {
|
q.add((q, done) => {
|
||||||
clock.tick(150000)
|
clock.tick(1000 * 10 * 60)
|
||||||
client.info((err, result) => {
|
client.info((err, result) => {
|
||||||
t.error(err)
|
t.error(err)
|
||||||
done()
|
done()
|
||||||
@ -194,7 +194,7 @@ test('Should execute the recurrect API with the optimistic strategy', t => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
q.add((q, done) => {
|
q.add((q, done) => {
|
||||||
clock.tick(10)
|
clock.tick(1000 * 61)
|
||||||
client.info((err, result) => {
|
client.info((err, result) => {
|
||||||
t.error(err)
|
t.error(err)
|
||||||
done()
|
done()
|
||||||
|
|||||||
Reference in New Issue
Block a user