The package load-balance-algorithm implements two kinds of Round-Robin algorithm.
example to use it:
func SmoothRoundRobinAlg_Next(t *testing.T) {
smoothRoundRobinAlg := &SmoothRoundRobinAlg{}
smoothRoundRobinAlg.Add("A", 5)
smoothRoundRobinAlg.Add("B", 2)
smoothRoundRobinAlg.Add("C", 3)
for i:=0; i<10; i++ {
fmt.Printf("%s ", smoothRoundRobinAlg.Next())
}
}
example to use it:
func RoundRobinAlg_Next() {
roundRobinAlg := &RoundRobinAlg{}
roundRobinAlg.Add("A", 5)
roundRobinAlg.Add("B", 2)
roundRobinAlg.Add("C", 3)
for i:=0; i<10; i++ {
fmt.Printf("%s ", roundRobinAlg.Next())
}
}