Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Weight ¶
type Weight interface { // Next gets next selected item. // Next is goroutine-safe. You don't use the snchronization primitive to protect it in concurrent cases. Next() (item interface{}) // Add adds a weighted item for selection. if adds an exit item ,weight plussed Add(item interface{}, weight int) //All returns all items. All() map[interface{}]int // Reset resets the balancing algorithm. Reset() // RemoveAll removes all weighted items. Next will return nil if remove all RemoveAll() OnChange(c *Config) }
Weight is a interface that implement a weighted round robin algorithm.
type WeightedRR ¶
type WeightedRR struct {
// contains filtered or unexported fields
}
WeightedRR ...
func NewWeightedRR ¶
func NewWeightedRR(c *Config) *WeightedRR
func (*WeightedRR) Add ¶
func (w *WeightedRR) Add(item interface{}, weight int)
func (*WeightedRR) All ¶
func (w *WeightedRR) All() map[interface{}]int
func (*WeightedRR) OnChange ¶
func (w *WeightedRR) OnChange(c *Config)
func (*WeightedRR) RemoveAll ¶
func (w *WeightedRR) RemoveAll()
func (*WeightedRR) Reset ¶
func (w *WeightedRR) Reset()
Click to show internal directories.
Click to hide internal directories.