1
0
Fork 0

Update to go1.23

This commit is contained in:
Michel Loiseleur 2024-08-28 15:00:06 +02:00 committed by GitHub
parent d2030a5835
commit e56ae1a766
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
41 changed files with 113 additions and 119 deletions

View file

@ -61,13 +61,13 @@ func (b *WRRLoadBalancer) AddWeightedServer(serverHandler Handler, weight *int)
}
func (b *WRRLoadBalancer) maxWeight() int {
max := -1
maximum := -1
for _, s := range b.servers {
if s.weight > max {
max = s.weight
if s.weight > maximum {
maximum = s.weight
}
}
return max
return maximum
}
func (b *WRRLoadBalancer) weightGcd() int {
@ -99,8 +99,8 @@ func (b *WRRLoadBalancer) next() (Handler, error) {
// what interleaves servers and allows us not to build an iterator every time we readjust weights.
// Maximum weight across all enabled servers
max := b.maxWeight()
if max == 0 {
maximum := b.maxWeight()
if maximum == 0 {
return nil, errors.New("all servers have 0 weight")
}
@ -112,7 +112,7 @@ func (b *WRRLoadBalancer) next() (Handler, error) {
if b.index == 0 {
b.currentWeight -= gcd
if b.currentWeight <= 0 {
b.currentWeight = max
b.currentWeight = maximum
}
}
srv := b.servers[b.index]