Documentation ¶
Index ¶
Constants ¶
View Source
const (
//DefaultVirualSpots default virual spots
DefaultVirualSpots = 400
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HashLoadBalancer ¶
type HashLoadBalancer struct { }
func NewHashLoadBalancer ¶
func NewHashLoadBalancer() *HashLoadBalancer
func (*HashLoadBalancer) SelectService ¶
func (loadBalance *HashLoadBalancer) SelectService(services []*discovery.InstanceInfo) (*discovery.InstanceInfo, error)
func (*HashLoadBalancer) SelectServiceByKey ¶
func (loadBalance *HashLoadBalancer) SelectServiceByKey(services []*discovery.InstanceInfo, key string) (*discovery.InstanceInfo, error)
type HashRing ¶
type HashRing struct {
// contains filtered or unexported fields
}
HashRing store nodes and weigths
func (*HashRing) UpdateNode ¶
UpdateNode update node with weight
type LoadBalancer ¶
type LoadBalancer interface { SelectService(service []*discovery.InstanceInfo) (*discovery.InstanceInfo, error) SelectServiceByKey(service []*discovery.InstanceInfo, key string) (*discovery.InstanceInfo, error) }
负载均衡器
type RandomLoadBalancer ¶
type RandomLoadBalancer struct { }
func NewRandomLoadBalancer ¶
func NewRandomLoadBalancer() *RandomLoadBalancer
func (*RandomLoadBalancer) SelectService ¶
func (loadBalance *RandomLoadBalancer) SelectService(services []*discovery.InstanceInfo) (*discovery.InstanceInfo, error)
随机负载均衡
func (*RandomLoadBalancer) SelectServiceByKey ¶
func (loadBalance *RandomLoadBalancer) SelectServiceByKey(services []*discovery.InstanceInfo, key string) (*discovery.InstanceInfo, error)
type WeightRoundRobinLoadBalancer ¶
type WeightRoundRobinLoadBalancer struct { }
func NewWeightRoundRobinLoadBalancer ¶
func NewWeightRoundRobinLoadBalancer() *WeightRoundRobinLoadBalancer
func (*WeightRoundRobinLoadBalancer) SelectService ¶
func (loadBalance *WeightRoundRobinLoadBalancer) SelectService(services []*discovery.InstanceInfo) (best *discovery.InstanceInfo, err error)
权重平滑负载均衡
func (*WeightRoundRobinLoadBalancer) SelectServiceByKey ¶
func (loadBalance *WeightRoundRobinLoadBalancer) SelectServiceByKey(services []*discovery.InstanceInfo, key string) (*discovery.InstanceInfo, error)
Click to show internal directories.
Click to hide internal directories.