fix bug with all zero weights

This commit is contained in:
mantaohuang 2020-04-10 10:25:59 -04:00
parent 98dc22aeda
commit 2a025ffa94
2 changed files with 5 additions and 1 deletions

View File

@ -1,3 +1,3 @@
{
"weights": [0, 0, 0, 2]
"weights": [1, 0, 0, 0]
}

View File

@ -151,6 +151,10 @@ func (pm *ProxyManager) applyWeight() {
chooseArr = append(chooseArr, wr.Choice{Item: len(pm.enabledIndics) - 1, Weight: uint(p.Weight)})
}
}
if len(pm.enabledIndics) == 0 {
fmt.Println("no enabled indice, proxy will be disabled.")
return
}
fmt.Println("enabled indices:", pm.enabledIndics)
pm.Chooser = wr.NewChooser(chooseArr...)
// update cache to remove disabled proxys