may the force be with me
This commit is contained in:
@@ -538,10 +538,22 @@ func (sc *StatsCollector) AddStats(stats []ResponseStats, totalDuration time.Dur
|
|||||||
hasActualFirst = true
|
hasActualFirst = true
|
||||||
method = stat.Method
|
method = stat.Method
|
||||||
} else if stat.Error == nil && stat.Duration < fastestDuration {
|
} else if stat.Error == nil && stat.Duration < fastestDuration {
|
||||||
fastestDuration = stat.Duration
|
// Primary backend can always be fastest, secondary only if successful status
|
||||||
fastestBackend = stat.Backend
|
canBeWinner := false
|
||||||
if method == "" {
|
if stat.Backend == "primary" {
|
||||||
method = stat.Method
|
// Primary can always be winner (regardless of status code)
|
||||||
|
canBeWinner = true
|
||||||
|
} else {
|
||||||
|
// Secondary backend can only be winner with successful status code
|
||||||
|
canBeWinner = stat.StatusCode < 400
|
||||||
|
}
|
||||||
|
|
||||||
|
if canBeWinner {
|
||||||
|
fastestDuration = stat.Duration
|
||||||
|
fastestBackend = stat.Backend
|
||||||
|
if method == "" {
|
||||||
|
method = stat.Method
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user