balance

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoneAvailable = errors.New("none available")

Functions

This section is empty.

Types

type Balancer

type Balancer struct {
	// contains filtered or unexported fields
}

func New

func New(selector Selector, next http.Handler) *Balancer

func (*Balancer) Name

func (b *Balancer) Name() middlewares.HandlerName

func (*Balancer) NodeList

func (b *Balancer) NodeList() []*Node

func (*Balancer) ServeHTTP

func (b *Balancer) ServeHTTP(writer http.ResponseWriter, request *http.Request)

func (*Balancer) Update

func (b *Balancer) Update(add bool, node *Node)

type Heap

type Heap struct {
	// contains filtered or unexported fields
}

func NewHeap

func NewHeap() *Heap

func (*Heap) Len

func (h *Heap) Len() int

func (*Heap) Less

func (h *Heap) Less(i, j int) bool

func (*Heap) List

func (h *Heap) List() []*Node

func (*Heap) Next

func (h *Heap) Next() (*Node, error)

func (*Heap) Pop

func (h *Heap) Pop() interface{}

func (*Heap) Push

func (h *Heap) Push(x interface{})

func (*Heap) Swap

func (h *Heap) Swap(i, j int)

func (*Heap) Update

func (h *Heap) Update(add bool, node *Node)

type Node

type Node struct {
	Scheme   string            `json:"scheme"`
	Host     string            `json:"host"`
	Metadata map[string]string `json:"metadata"`
	Weight   float64           `json:"weight"`
}

type Random

type Random struct {
	// contains filtered or unexported fields
}

func NewRandom

func NewRandom() *Random

func (*Random) List

func (r *Random) List() []*Node

func (*Random) Next

func (r *Random) Next() (*Node, error)

func (*Random) Update

func (r *Random) Update(add bool, node *Node)

type RoundRobin

type RoundRobin struct {
	// contains filtered or unexported fields
}

func NewRoundRobin

func NewRoundRobin() *RoundRobin

func (*RoundRobin) List

func (r *RoundRobin) List() []*Node

func (*RoundRobin) Next

func (r *RoundRobin) Next() (*Node, error)

func (*RoundRobin) Update

func (r *RoundRobin) Update(add bool, node *Node)

type Selector

type Selector interface {
	Update(bool, *Node)
	Next() (*Node, error)
	List() []*Node
}

Selector strategy algorithm

Jump to

Keyboard shortcuts

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