wrr

package
v2.0.0-...-29d9702 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 26, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

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) *Balancer

New creates a new load balancer.

func (*Balancer) AddService

func (b *Balancer) AddService(name string, handler http.Handler, weight *int)

AddService adds a handler. It is not thread safe with ServeHTTP. A handler with a non-positive weight is ignored.

func (*Balancer) Len

func (b *Balancer) Len() int

Len implements heap.Interface/sort.Interface.

func (*Balancer) Less

func (b *Balancer) Less(i, j int) bool

Less implements heap.Interface/sort.Interface.

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) ServeHTTP

func (b *Balancer) ServeHTTP(w http.ResponseWriter, req *http.Request)

func (*Balancer) Swap

func (b *Balancer) Swap(i, j int)

Swap implements heap.Interface/sort.Interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL