Documentation ¶
Index ¶
- type Balancer
- func (b *Balancer) AddService(name string, handler http.Handler, weight *int)
- func (b *Balancer) Len() int
- func (b *Balancer) Less(i, j int) bool
- func (b *Balancer) Pop() interface{}
- func (b *Balancer) Push(x interface{})
- func (b *Balancer) RegisterStatusUpdater(fn func(up bool)) error
- func (b *Balancer) ServeHTTP(w http.ResponseWriter, req *http.Request)
- func (b *Balancer) SetStatus(ctx context.Context, childName string, up bool)
- func (b *Balancer) Swap(i, j int)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Balancer ¶
type Balancer struct {
// contains filtered or unexported fields
}
Balancer is a WeightedRoundRobin load balancer based on Earliest Deadline First (EDF). (https://en.wikipedia.org/wiki/Earliest_deadline_first_scheduling) Each pick from the schedule has the earliest deadline entry selected. Entries have deadlines set at currentDeadline + 1 / weight, providing weighted round robin behavior with floating point weights and an O(log n) pick time.
func New ¶
func New(sticky *dynamic.Sticky, hc *dynamic.HealthCheck) *Balancer
New creates a new load balancer.
func (*Balancer) AddService ¶
AddService adds a handler. A handler with a non-positive weight is ignored.
func (*Balancer) Pop ¶
func (b *Balancer) Pop() interface{}
Pop implements heap.Interface for poping an item from the heap. It panics if b.Len() < 1.
func (*Balancer) Push ¶
func (b *Balancer) Push(x interface{})
Push implements heap.Interface for pushing an item into the heap.
func (*Balancer) RegisterStatusUpdater ¶ added in v2.5.0
RegisterStatusUpdater adds fn to the list of hooks that are run when the status of the Balancer changes. Not thread safe.