fixed another reload bug

This commit is contained in:
ston1th 2021-04-10 16:16:45 +02:00
commit 8672452033

View file

@ -1,6 +1,9 @@
package haproxy
import "encoding/json"
import (
"encoding/json"
"sort"
)
type Config struct {
LoadBalancers []*LoadBalancer
@ -15,6 +18,11 @@ func NewConfig(m map[string][]byte) (c Config, err error) {
}
c.LoadBalancers = append(c.LoadBalancers, lb)
}
if len(c.LoadBalancers) > 1 {
sort.SliceStable(c.LoadBalancers, func(i, j int) bool {
return c.LoadBalancers[i].Name < c.LoadBalancers[j].Name
})
}
return
}