} else {
t.verifyPeerCer, t.verifyPeerCerErr = os.ReadFile(path)
}
+ if t.lastChosenT.IsZero() {
+ t.lastChosenT = time.Now()
+ }
t.AlwaysUp = len(t.route.Backs) == 1 || t.AlwaysUp
}
import (
"math/rand/v2"
"slices"
+ "time"
)
var rollRuleMap = make(map[string]func(backLink []*Back))
rollRuleMap[`loop`] = func(backLink []*Back) {
slices.SortStableFunc(backLink, func(a, b *Back) int {
- return a.lastChosenT.Compare(b.lastChosenT)
+ return int(time.Since(a.lastChosenT).Milliseconds()/int64(a.Weight+1) - time.Since(b.lastChosenT).Milliseconds()/int64(b.Weight+1))
})
}
}