loadbalancer

package
v0.0.0-...-6e90328 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Endpoint

type Endpoint interface {
	Weight() int
	fmt.Stringer
}

type LoadBalancer

type LoadBalancer interface {
	Select() Endpoint
	AddEndpoint(e Endpoint)
	DelEndpoint(e Endpoint)
}

func NewLoadBalancer

func NewLoadBalancer(strategy Strategy, endpoints ...Endpoint) LoadBalancer

NewLoadBalancer returns the specified load balancer according to strategy, and initializes with endpoints

Random: The random load balancer forwards a client request randomly. RoundRobin: The round-robin load balancer forwards a client request to each endpoint in turn. WeightedRoundRobin: In the weighted round-robin algorithm, each endpoints is assigned a value that signifies, relative to the other endpoints in the pool, how that endpoint performs.

type Strategy

type Strategy uint8
const (
	Random Strategy = iota
	RoundRobin
	WeightedRoundRobin
)

Jump to

Keyboard shortcuts

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