mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-23 16:58:31 +02:00
refactor(http): enhance health check error logic by treating all 5xx as unhealthy
This commit is contained in:
@@ -60,8 +60,7 @@ func (mon *HTTPHealthMonitor) CheckHealth() (types.HealthCheckResult, error) {
|
|||||||
respErr := pinger.DoTimeout(req, resp, mon.config.Timeout)
|
respErr := pinger.DoTimeout(req, resp, mon.config.Timeout)
|
||||||
lat := time.Since(start)
|
lat := time.Since(start)
|
||||||
|
|
||||||
switch {
|
if respErr != nil {
|
||||||
case respErr != nil:
|
|
||||||
// treat TLS error as healthy
|
// treat TLS error as healthy
|
||||||
var tlsErr *tls.CertificateVerificationError
|
var tlsErr *tls.CertificateVerificationError
|
||||||
if ok := errors.As(respErr, &tlsErr); !ok {
|
if ok := errors.As(respErr, &tlsErr); !ok {
|
||||||
@@ -70,7 +69,9 @@ func (mon *HTTPHealthMonitor) CheckHealth() (types.HealthCheckResult, error) {
|
|||||||
Detail: respErr.Error(),
|
Detail: respErr.Error(),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
case resp.StatusCode() == fasthttp.StatusServiceUnavailable:
|
}
|
||||||
|
|
||||||
|
if status := resp.StatusCode(); status >= 500 && status < 600 {
|
||||||
return types.HealthCheckResult{
|
return types.HealthCheckResult{
|
||||||
Latency: lat,
|
Latency: lat,
|
||||||
Detail: fasthttp.StatusMessage(resp.StatusCode()),
|
Detail: fasthttp.StatusMessage(resp.StatusCode()),
|
||||||
|
|||||||
Reference in New Issue
Block a user