wrr

package
v2.11.2 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: MIT Imports: 9 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, hc *dynamic.HealthCheck) *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. 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 popping 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

func (b *Balancer) RegisterStatusUpdater(fn func(up bool)) error

RegisterStatusUpdater adds fn to the list of hooks that are run when the status of the Balancer changes. Not thread safe.

func (*Balancer) ServeHTTP

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

func (*Balancer) SetStatus added in v2.5.0

func (b *Balancer) SetStatus(ctx context.Context, childName string, up bool)

SetStatus sets on the balancer that its given child is now of the given status. balancerName is only needed for logging purposes.

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