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)
| 107 | // It detects degraded (high-latency) responses and makes |
| 108 | // the conclusion about the result's status. |
| 109 | func (c Checker) conclude(result types.Result) types.Result { |
| 110 | result.ThresholdRTT = c.ThresholdRTT |
| 111 | |
| 112 | // Check errors (down) |
| 113 | for i := range result.Times { |
| 114 | if result.Times[i].Error != "" { |
| 115 | result.Down = true |
| 116 | return result |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | // Check round trip time (degraded) |
| 121 | if c.ThresholdRTT > 0 { |
| 122 | stats := result.ComputeStats() |
| 123 | if stats.Median > c.ThresholdRTT { |
| 124 | result.Notice = fmt.Sprintf("median round trip time exceeded threshold (%s)", c.ThresholdRTT) |
| 125 | result.Degraded = true |
| 126 | return result |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | result.Healthy = true |
| 131 | return result |
| 132 | } |