mirror of
https://github.com/yusing/godoxy.git
synced 2025-05-19 20:32:35 +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
|
||||
return
|
||||
}
|
||||
|
||||
req.Close = true
|
||||
req.Header.Set("Connection", "close")
|
||||
req.Header.Set("User-Agent", "GoDoxy/"+pkg.GetVersion())
|
||||
|
||||
start := time.Now()
|
||||
resp, respErr := pinger.Do(req)
|
||||
if respErr == nil {
|
||||
resp.Body.Close()
|
||||
defer resp.Body.Close()
|
||||
}
|
||||
|
||||
result = &health.HealthCheckResult{
|
||||
Latency: time.Since(start),
|
||||
}
|
||||
lat := time.Since(start)
|
||||
result = &health.HealthCheckResult{}
|
||||
|
||||
switch {
|
||||
case respErr != nil:
|
||||
|
@ -82,6 +81,7 @@ func (mon *HTTPHealthMonitor) CheckHealth() (result *health.HealthCheckResult, e
|
|||
return
|
||||
}
|
||||
|
||||
result.Latency = lat
|
||||
result.Healthy = true
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue