Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChooseInstance ¶
func ChooseInstance(ctx model.ValueContext, loadbalancer LoadBalancer, criteria *Criteria, instances model.ServiceInstances) (model.Instance, model.SDKError)
ChooseInstance 执行负载均衡
Types ¶
type Criteria ¶
type Criteria struct { // 用户传入用于计算hash的二进制流 HashKey []byte // 用户传入用于计算hash的int值 HashValue uint64 // 分配时忽略半开实例,只有当没有其他节点时才分配半开节点 IgnoreHalfOpen bool // 必选,目标cluster Cluster *model.Cluster // 可选,对于有状态的负载均衡方式,这里给出备份节点的返回数据 ReplicateInfo ReplicateInfo }
Criteria 负载均衡的过滤值成员
type LoadBalancer ¶
type LoadBalancer interface { plugin.Plugin // ChooseInstance 进行负载均衡,选择一个实例 ChooseInstance(criteria *Criteria, instances model.ServiceInstances) (model.Instance, error) }
LoadBalancer 【扩展点接口】负载均衡
type Proxy ¶
type Proxy struct { LoadBalancer // contains filtered or unexported fields }
Proxy of LoadBalancer
func (*Proxy) ChooseInstance ¶
func (p *Proxy) ChooseInstance(criteria *Criteria, instances model.ServiceInstances) (model.Instance, error)
ChooseInstance proxy LoadBalancer ChooseInstance
type ReplicateInfo ¶
ReplicateInfo 备份节点信息
type SelectStatus ¶
SelectStatus 获取负载均衡状态
Click to show internal directories.
Click to hide internal directories.