feat(failover): treat alternatives cyclically

This commit is contained in:
Gregor Kleen 2020-07-28 20:04:44 +02:00
parent d6f0d28a1f
commit 9213b7554a

View File

@ -161,9 +161,12 @@ withFailover' testTarget' f@Failover{..} mode detAcceptable act = withFailoverRe
$logErrorS "withFailover'" $ tshow (hashUnique alreadyTested) <> " recording failure for item " <> failoverLabel
atomically . modifyTVar failover $ \failover' -> if
| views (P.focus . _failoverReferences) (Set.member currentlyTesting) failover'
-> fromMaybe failover' $ P.next failover'
-> fromMaybe (goFirst failover') $ P.next failover'
| otherwise
-> failover'
where goFirst l = case P.previous l of
Nothing -> l
Just l' -> goFirst l'
$logDebugS "withFailover'" $ tshow (hashUnique alreadyTested) <> " using item " <> failoverLabel
res' <- handleAll (\err -> $logErrorS "withFailover'" (tshow (hashUnique alreadyTested) <> " exception during act or detAcceptable: " <> tshow err) >> recordFailure >> throwM err) $