balancer

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2019 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WeightedRoundRobinRule = "wwr"
	AddressHash            = "addr_hash"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BalancedService

type BalancedService struct {
	Client  *discover.RestClient   //rest client for rpc
	Service *discover.MicroService //picked instance
	// contains filtered or unexported fields
}

type Balancer

type Balancer interface {
	//pick the best instance for a request
	PickInstance(serviceName string, ctx *common.RequestCtx) *BalancedService

	//notify the balancer good call or a network problem
	NotifyEffect(service *BalancedService, ok bool)

	//refresh balancer's instance
	RefreshInstance(instanceList map[string][]discover.MicroService)
}

type LoadBalanceRule

type LoadBalanceRule string

type WRRBalancer

type WRRBalancer struct {
	Balancer

	sync.RWMutex
	// contains filtered or unexported fields
}

func NewWRRBalancer

func NewWRRBalancer(timeout time.Duration) *WRRBalancer

func (*WRRBalancer) NotifyEffect

func (s *WRRBalancer) NotifyEffect(bs *BalancedService, ok bool)

func (*WRRBalancer) PickInstance

func (s *WRRBalancer) PickInstance(serviceName string, ctx *common.RequestCtx) *BalancedService

func (*WRRBalancer) RefreshInstance

func (s *WRRBalancer) RefreshInstance(instanceList map[string][]discover.MicroService)

Jump to

Keyboard shortcuts

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