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) ServeHTTP(w http.ResponseWriter, req *http.Request)
- 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 (*Balancer) AddService ¶
AddService adds a handler. It is not thread safe with ServeHTTP. 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.
Click to show internal directories.
Click to hide internal directories.