balancer

package
v0.0.0-...-9c84b05 Latest Latest
Warning

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

Go to latest
Published: May 31, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoAliveServers = errors.New("no alive replicas")
)

Functions

This section is empty.

Types

type Balancer

type Balancer interface {
	// Next returns the next server to be used
	Next() (*common.Server, error)
	// Add adds a new server to the balancer
	Add(*common.Server)

	HealthChecker() *health.HealthChecker

	SetHealthChecker(*health.HealthChecker)
}

Balancer is an interface that defines the behavior of a load balancer

type RR

type RR struct {
	Hc *health.HealthChecker
	// contains filtered or unexported fields
}

Round Robin Balancer will select the next server in the list of servers in a round robin fashion. This is the default balancer used by Mizan. Equivalent to Weighted Round Robin with all weights set to 1.

func NewRR

func NewRR(servers []*common.Server) *RR

func (*RR) Add

func (rr *RR) Add(s *common.Server)

func (*RR) HealthChecker

func (rr *RR) HealthChecker() *health.HealthChecker

func (*RR) Next

func (rr *RR) Next() (*common.Server, error)

func (*RR) SetHealthChecker

func (rr *RR) SetHealthChecker(hc *health.HealthChecker)

type WRR

type WRR struct {
	Hc *health.HealthChecker
	// contains filtered or unexported fields
}

Weighted Round Robin Balancer This is a weighted version of the Round Robin Balancer Each server has a weight associated with it, and the load balancer will select the next server based on the weight of each server If the weight of server is not specified, it will be set to 1 TODO (Mo-Fatah): Add support for calculating live connecitons to each server and use that as a weight

func NewWRR

func NewWRR(servers []*common.Server) *WRR

func (*WRR) Add

func (wrr *WRR) Add(s *common.Server)

func (*WRR) HealthChecker

func (rr *WRR) HealthChecker() *health.HealthChecker

func (*WRR) Next

func (wrr *WRR) Next() (*common.Server, error)

Next returns the next server to be used based on the weight of each server.

func (*WRR) SetHealthChecker

func (rr *WRR) SetHealthChecker(hc *health.HealthChecker)

Jump to

Keyboard shortcuts

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