loadbalance

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyBalance    = errors.New("balance data is empty")
	ErrEmptyKeyForHash = errors.New("hash balance key is empty")
)

Functions

This section is empty.

Types

type Balance

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

func NewBalance

func NewBalance(addr string, port, weight int64) *Balance

func (*Balance) Addr

func (lb *Balance) Addr() string

func (*Balance) CallTimes

func (lb *Balance) CallTimes() int64

func (*Balance) Port

func (lb *Balance) Port() int64

func (*Balance) String

func (lb *Balance) String() string

func (*Balance) Weight

func (lb *Balance) Weight() int64

type Hash

type Hash struct{}

func (*Hash) DoBalance

func (lb *Hash) DoBalance(balance []*Balance, key string) (b *Balance, err error)

type LoadBalancer

type LoadBalancer interface {
	DoBalance(balance []*Balance, key string) (b *Balance, err error)
}

LoadBalancer refer to https://github.com/henkgo/blancer

type Random

type Random struct{}

func (*Random) DoBalance

func (lb *Random) DoBalance(balance []*Balance, key string) (b *Balance, err error)

type RoundRobin

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

func (*RoundRobin) DoBalance

func (lb *RoundRobin) DoBalance(balance []*Balance, key string) (b *Balance, err error)

type RoundRobinWeight

type RoundRobinWeight struct{}

func (*RoundRobinWeight) DoBalance

func (lb *RoundRobinWeight) DoBalance(balance []*Balance, key string) (b *Balance, err error)

type Shuffle

type Shuffle struct {
	Mode int
}

func (*Shuffle) DoBalance

func (lb *Shuffle) DoBalance(balance []*Balance, key string) (b *Balance, err error)

Jump to

Keyboard shortcuts

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