load_balancer

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

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

Go to latest
Published: Sep 26, 2018 License: Apache-2.0 Imports: 13 Imported by: 0

README

Documentation

Index

Constants

View Source
const (
	DefaultReplicas = 10
)

Variables

View Source
var (
	DefaultKetamaKey  = "grpc-lb-ketama-key"
	KetamaKeyEmptyErr = errors.New("ketama key is empty")
)
View Source
var AddrDoseNotExistErr = errors.New("addr does not exist")
View Source
var AddrExistErr = errors.New("addr exist")
View Source
var AddrListEmptyErr = errors.New("addr list is emtpy")
View Source
var DefaultSelector = NewRandomSelector()
View Source
var NoAvailableAddressErr = errors.New("no available address")

Functions

func NewBalancer

func NewBalancer(r naming.Resolver, selector Selector) grpc.Balancer

Types

type AddrInfo

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

type HashFunc

type HashFunc func(data []byte) uint32

type Ketama

type Ketama struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewKetama

func NewKetama(replicas int, fn HashFunc) *Ketama

func (*Ketama) Add

func (h *Ketama) Add(nodes ...string)

func (*Ketama) Get

func (h *Ketama) Get(key string) (string, bool)

func (*Ketama) IsEmpty

func (h *Ketama) IsEmpty() bool

func (*Ketama) Remove

func (h *Ketama) Remove(nodes ...string)

type KetamaSelector

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

func (*KetamaSelector) Add

func (s *KetamaSelector) Add(addr grpc.Address) error

func (*KetamaSelector) AddrList

func (b *KetamaSelector) AddrList() []grpc.Address

func (*KetamaSelector) Delete

func (s *KetamaSelector) Delete(addr grpc.Address) error

func (*KetamaSelector) Down

func (b *KetamaSelector) Down(addr grpc.Address) error

func (*KetamaSelector) Get

func (s *KetamaSelector) Get(ctx context.Context) (addr grpc.Address, err error)

func (*KetamaSelector) Put

func (b *KetamaSelector) Put(addr string) error

func (*KetamaSelector) Up

func (b *KetamaSelector) Up(addr grpc.Address) (cnt int, connected bool)

type RandomSelector

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

func (*RandomSelector) Add

func (b *RandomSelector) Add(addr grpc.Address) error

func (*RandomSelector) AddrList

func (b *RandomSelector) AddrList() []grpc.Address

func (*RandomSelector) Delete

func (b *RandomSelector) Delete(addr grpc.Address) error

func (*RandomSelector) Down

func (b *RandomSelector) Down(addr grpc.Address) error

func (*RandomSelector) Get

func (r *RandomSelector) Get(ctx context.Context) (addr grpc.Address, err error)

func (*RandomSelector) Put

func (b *RandomSelector) Put(addr string) error

func (*RandomSelector) Up

func (b *RandomSelector) Up(addr grpc.Address) (cnt int, connected bool)

type RoundRobinSelector

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

func (*RoundRobinSelector) Add

func (b *RoundRobinSelector) Add(addr grpc.Address) error

func (*RoundRobinSelector) AddrList

func (b *RoundRobinSelector) AddrList() []grpc.Address

func (*RoundRobinSelector) Delete

func (b *RoundRobinSelector) Delete(addr grpc.Address) error

func (*RoundRobinSelector) Down

func (b *RoundRobinSelector) Down(addr grpc.Address) error

func (*RoundRobinSelector) Get

func (r *RoundRobinSelector) Get(ctx context.Context) (addr grpc.Address, err error)

func (*RoundRobinSelector) Put

func (b *RoundRobinSelector) Put(addr string) error

func (*RoundRobinSelector) Up

func (b *RoundRobinSelector) Up(addr grpc.Address) (cnt int, connected bool)

type Selector

type Selector interface {
	Add(addr grpc.Address) error
	Delete(addr grpc.Address) error
	Up(addr grpc.Address) (cnt int, connected bool)
	Down(addr grpc.Address) error
	AddrList() []grpc.Address
	Get(ctx context.Context) (grpc.Address, error)
	Put(addr string) error
}

func NewKetamaSelector

func NewKetamaSelector(ketamaKey string) Selector

func NewRandomSelector

func NewRandomSelector() Selector

func NewRoundRobinSelector

func NewRoundRobinSelector() Selector

Jump to

Keyboard shortcuts

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