balancer

package
v0.0.0-...-9391939 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BalancerTypeRR      = "RR"
	BalancerTypeWRR     = "WRR"
	BalancerTypeRandom  = "RANDOM"
	BalancerTypeWRandom = "WRANDOM"
	BalancerTypeHash    = "HASH"
	BalancerTypeCHash   = "CHASH"
)

Variables

View Source
var (
	ErrNoBalancer = errors.New("no balancer available")
)

Functions

This section is empty.

Types

type Balancer

type Balancer interface {
	Name() string
	NewPicker([]instance.Instance) Picker
}

func CreateBalancer

func CreateBalancer(name string) (Balancer, error)

func NewCHashBalancer

func NewCHashBalancer(fs ...HashFunc64) Balancer

func NewHashBalancer

func NewHashBalancer(fs ...HashFunc) Balancer

func NewRRBalancer

func NewRRBalancer() Balancer

func NewRandomBalancer

func NewRandomBalancer() Balancer

func NewWRRBalancer

func NewWRRBalancer() Balancer

func NewWRandomBalancer

func NewWRandomBalancer() Balancer

type CHashBalancer

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

func (*CHashBalancer) Name

func (b *CHashBalancer) Name() string

func (*CHashBalancer) NewPicker

func (b *CHashBalancer) NewPicker(instances []instance.Instance) Picker

type HashBalancer

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

func (*HashBalancer) Name

func (b *HashBalancer) Name() string

func (*HashBalancer) NewPicker

func (b *HashBalancer) NewPicker(instances []instance.Instance) Picker

type HashFunc

type HashFunc func([]byte) uint32

type HashFunc64

type HashFunc64 func([]byte) uint64

type Picker

type Picker interface {
	Pick(...string) (instance.Instance, error)
}

type RRBalancer

type RRBalancer struct {
}

func (*RRBalancer) Name

func (b *RRBalancer) Name() string

func (*RRBalancer) NewPicker

func (b *RRBalancer) NewPicker(instances []instance.Instance) Picker

type RandomBalancer

type RandomBalancer struct {
}

func (*RandomBalancer) Name

func (b *RandomBalancer) Name() string

func (*RandomBalancer) NewPicker

func (b *RandomBalancer) NewPicker(instances []instance.Instance) Picker

type WRRBalancer

type WRRBalancer struct {
}

func (*WRRBalancer) Name

func (b *WRRBalancer) Name() string

func (*WRRBalancer) NewPicker

func (b *WRRBalancer) NewPicker(instances []instance.Instance) Picker

type WRandomBalancer

type WRandomBalancer struct {
}

func (*WRandomBalancer) Name

func (b *WRandomBalancer) Name() string

func (*WRandomBalancer) NewPicker

func (b *WRandomBalancer) NewPicker(instances []instance.Instance) Picker

Jump to

Keyboard shortcuts

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