may the force be with me

This commit is contained in:
Para Dox
2025-05-29 18:58:29 +07:00
parent 7cf79509e3
commit e4f6ca8ee7

View File

@@ -538,6 +538,17 @@ 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 {
// 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 fastestDuration = stat.Duration
fastestBackend = stat.Backend fastestBackend = stat.Backend
if method == "" { if method == "" {
@@ -545,6 +556,7 @@ func (sc *StatsCollector) AddStats(stats []ResponseStats, totalDuration time.Dur
} }
} }
} }
}
// Track the win if we found a successful response // Track the win if we found a successful response
if fastestBackend != "" { if fastestBackend != "" {