Documentation ¶
Index ¶
- Constants
- Variables
- func NewBalancer(r naming.Resolver, selector Selector) grpc.Balancer
- type AddrInfo
- type HashFunc
- type Ketama
- type KetamaSelector
- func (s *KetamaSelector) Add(addr grpc.Address) error
- func (b *KetamaSelector) AddrList() []grpc.Address
- func (s *KetamaSelector) Delete(addr grpc.Address) error
- func (b *KetamaSelector) Down(addr grpc.Address) error
- func (s *KetamaSelector) Get(ctx context.Context) (addr grpc.Address, err error)
- func (b *KetamaSelector) Put(addr string) error
- func (b *KetamaSelector) Up(addr grpc.Address) (cnt int, connected bool)
- type RandomSelector
- func (b *RandomSelector) Add(addr grpc.Address) error
- func (b *RandomSelector) AddrList() []grpc.Address
- func (b *RandomSelector) Delete(addr grpc.Address) error
- func (b *RandomSelector) Down(addr grpc.Address) error
- func (r *RandomSelector) Get(ctx context.Context) (addr grpc.Address, err error)
- func (b *RandomSelector) Put(addr string) error
- func (b *RandomSelector) Up(addr grpc.Address) (cnt int, connected bool)
- type RoundRobinSelector
- func (b *RoundRobinSelector) Add(addr grpc.Address) error
- func (b *RoundRobinSelector) AddrList() []grpc.Address
- func (b *RoundRobinSelector) Delete(addr grpc.Address) error
- func (b *RoundRobinSelector) Down(addr grpc.Address) error
- func (r *RoundRobinSelector) Get(ctx context.Context) (addr grpc.Address, err error)
- func (b *RoundRobinSelector) Put(addr string) error
- func (b *RoundRobinSelector) Up(addr grpc.Address) (cnt int, connected bool)
- type Selector
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 ¶
Types ¶
type KetamaSelector ¶
type KetamaSelector struct {
// contains filtered or unexported fields
}
type RandomSelector ¶
type RandomSelector struct {
// contains filtered or unexported fields
}
type RoundRobinSelector ¶
type RoundRobinSelector struct {
// contains filtered or unexported fields
}
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 NewRandomSelector ¶
func NewRandomSelector() Selector
func NewRoundRobinSelector ¶
func NewRoundRobinSelector() Selector
Click to show internal directories.
Click to hide internal directories.