[Style] Positive health check
This commit is contained in:
parent
16abba385a
commit
4f1b227ca2
2 changed files with 9 additions and 3 deletions
|
@ -66,17 +66,20 @@ func (f *Fallback) onDialFailed() {
|
||||||
f.failedTime.Store(now)
|
f.failedTime.Store(now)
|
||||||
f.failedTimes.Store(1)
|
f.failedTimes.Store(1)
|
||||||
} else {
|
} else {
|
||||||
if f.failedTime.Load()-time.Now().UnixMilli() > 5*1000 {
|
if f.failedTime.Load()-time.Now().UnixMilli() > 5*time.Second.Milliseconds() {
|
||||||
f.failedTimes.Store(-1)
|
f.failedTimes.Store(-1)
|
||||||
f.failedTime.Store(-1)
|
f.failedTime.Store(-1)
|
||||||
} else {
|
} else {
|
||||||
failedCount := f.failedTimes.Inc()
|
failedCount := f.failedTimes.Inc()
|
||||||
log.Warnln("%s failed count: %d", f.Name(), failedCount)
|
log.Warnln("%s failed count: %d", f.Name(), failedCount)
|
||||||
if failedCount > 5 {
|
if failedCount >= 5 && failedCount < 6 {
|
||||||
log.Warnln("because %s failed multiple times, active health check", f.Name())
|
log.Warnln("because %s failed multiple times, active health check", f.Name())
|
||||||
for _, proxyProvider := range f.providers {
|
for _, proxyProvider := range f.providers {
|
||||||
go proxyProvider.HealthCheck()
|
go proxyProvider.HealthCheck()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
f.failedTimes.Store(-1)
|
||||||
|
f.failedTime.Store(-1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,11 +149,14 @@ func (u *URLTest) onDialFailed() {
|
||||||
} else {
|
} else {
|
||||||
failedCount := u.failedTimes.Inc()
|
failedCount := u.failedTimes.Inc()
|
||||||
log.Warnln("%s failed count: %d", u.Name(), failedCount)
|
log.Warnln("%s failed count: %d", u.Name(), failedCount)
|
||||||
if failedCount > 5 {
|
if failedCount >= 5 && failedCount < 6 {
|
||||||
log.Warnln("because %s failed multiple times, active health check", u.Name())
|
log.Warnln("because %s failed multiple times, active health check", u.Name())
|
||||||
for _, proxyProvider := range u.providers {
|
for _, proxyProvider := range u.providers {
|
||||||
go proxyProvider.HealthCheck()
|
go proxyProvider.HealthCheck()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u.failedTimes.Store(-1)
|
||||||
|
u.failedTime.Store(-1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue