github.com/fufuok/balancer@v1.0.0/default.go (about) 1 package balancer 2 3 // DefaultBalancer is an global balancer 4 var DefaultBalancer = NewWeightedRoundRobin() 5 6 // Add add an item to be selected. 7 func Add(item string, weight ...int) { 8 DefaultBalancer.Add(item, weight...) 9 } 10 11 // All get all items. 12 func All() interface{} { 13 return DefaultBalancer.All() 14 } 15 16 // Select gets next selected item. 17 func Select(_ ...string) string { 18 return DefaultBalancer.Select() 19 } 20 21 // Name load balancer name. 22 func Name() string { 23 return DefaultBalancer.Name() 24 } 25 26 // Remove remove an item. 27 func Remove(item string, _ ...bool) bool { 28 return DefaultBalancer.Remove(item) 29 } 30 31 // RemoveAll remove all items. 32 func RemoveAll() { 33 DefaultBalancer.RemoveAll() 34 } 35 36 // Reset reset the balancer. 37 func Reset() { 38 DefaultBalancer.Reset() 39 } 40 41 // Update reinitialize the balancer items. 42 func Update(items interface{}) bool { 43 return DefaultBalancer.Update(items) 44 }