mirror of
https://github.com/yusing/godoxy.git
synced 2025-07-11 16:44:03 +02:00
healthcheck: should not include latency when ping failed
This commit is contained in:
parent
29f85db022
commit
5a9fc3ad18
1 changed files with 5 additions and 5 deletions
|
@ -55,19 +55,18 @@ func (mon *HTTPHealthMonitor) CheckHealth() (result *health.HealthCheckResult, e
|
||||||
err = reqErr
|
err = reqErr
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
req.Close = true
|
||||||
req.Header.Set("Connection", "close")
|
req.Header.Set("Connection", "close")
|
||||||
req.Header.Set("User-Agent", "GoDoxy/"+pkg.GetVersion())
|
req.Header.Set("User-Agent", "GoDoxy/"+pkg.GetVersion())
|
||||||
|
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
resp, respErr := pinger.Do(req)
|
resp, respErr := pinger.Do(req)
|
||||||
if respErr == nil {
|
if respErr == nil {
|
||||||
resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
result = &health.HealthCheckResult{
|
lat := time.Since(start)
|
||||||
Latency: time.Since(start),
|
result = &health.HealthCheckResult{}
|
||||||
}
|
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
case respErr != nil:
|
case respErr != nil:
|
||||||
|
@ -82,6 +81,7 @@ func (mon *HTTPHealthMonitor) CheckHealth() (result *health.HealthCheckResult, e
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
result.Latency = lat
|
||||||
result.Healthy = true
|
result.Healthy = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue