conclude takes the data in result from the attempts and computes remaining values needed to fill out the result. It detects degraded (high-latency) responses and makes the conclusion about the result's status.
(result types.Result)
| 149 | // It detects degraded (high-latency) responses and makes |
| 150 | // the conclusion about the result's status. |
| 151 | func (c Checker) conclude(result types.Result) types.Result { |
| 152 | result.ThresholdRTT = c.ThresholdRTT |
| 153 | |
| 154 | // Check errors (down) |
| 155 | for i := range result.Times { |
| 156 | if result.Times[i].Error != "" { |
| 157 | result.Down = true |
| 158 | return result |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | // Check round trip time (degraded) |
| 163 | if c.ThresholdRTT > 0 { |
| 164 | stats := result.ComputeStats() |
| 165 | if stats.Median > c.ThresholdRTT { |
| 166 | result.Notice = fmt.Sprintf("median round trip time exceeded threshold (%s)", c.ThresholdRTT) |
| 167 | result.Degraded = true |
| 168 | return result |
| 169 | } |
| 170 | } |
| 171 | |
| 172 | result.Healthy = true |
| 173 | return result |
| 174 | } |
| 175 | |
| 176 | // checkDown checks whether the endpoint is down based on resp and |
| 177 | // the configuration of c. It returns a non-nil error if down. |