may the force be with me
This commit is contained in:
@@ -538,6 +538,17 @@ func (sc *StatsCollector) AddStats(stats []ResponseStats, totalDuration time.Dur
|
||||
hasActualFirst = true
|
||||
method = stat.Method
|
||||
} else if stat.Error == nil && stat.Duration < fastestDuration {
|
||||
// Primary backend can always be fastest, secondary only if successful status
|
||||
canBeWinner := false
|
||||
if stat.Backend == "primary" {
|
||||
// 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 == "" {
|
||||
@@ -545,6 +556,7 @@ func (sc *StatsCollector) AddStats(stats []ResponseStats, totalDuration time.Dur
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Track the win if we found a successful response
|
||||
if fastestBackend != "" {
|
||||
|
||||
Reference in New Issue
Block a user