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