上传rpcx 负载均衡代码
This commit is contained in:
parent
22283a26ff
commit
146eb77f4e
@ -333,16 +333,16 @@ func (this *Client) getclient(ctx *context.Context, clusterTag string, servicePa
|
||||
if d, err = client.NewConsulDiscovery(clusterTag, spath[0], this.options.ConsulServers, nil); err != nil {
|
||||
return
|
||||
}
|
||||
c = client.NewBidirectionalXClient(spath[0], client.Failfast, client.RandomSelect, d, client.DefaultOption, this.msgChan)
|
||||
c = client.NewBidirectionalXClient(spath[0], client.Failfast, client.RoundRobin, d, client.DefaultOption, this.msgChan)
|
||||
cluster.Mu.Lock()
|
||||
cluster.clients[spath[0]] = c
|
||||
cluster.Mu.Unlock()
|
||||
c.GetPlugins().Add(this)
|
||||
if this.options.RpcxStartType == RpcxStartByClient && this.options.AutoConnect {
|
||||
c.SetSelector(newSelector(this.options.Log, clusterTag, this.UpdateServer))
|
||||
} else {
|
||||
c.SetSelector(newSelector(this.options.Log, clusterTag, nil))
|
||||
}
|
||||
// if this.options.RpcxStartType == RpcxStartByClient && this.options.AutoConnect {
|
||||
c.SetSelector(newSelector(this.options.Log, clusterTag, this.UpdateServer))
|
||||
// } else {
|
||||
// c.SetSelector(newSelector(this.options.Log, clusterTag, nil))
|
||||
// }
|
||||
}
|
||||
|
||||
*ctx = context.WithValue(*ctx, share.ReqMetaDataKey, map[string]string{
|
||||
|
@ -103,11 +103,11 @@ func (this *Selector) UpdateServer(servers map[string]string) {
|
||||
continue
|
||||
} else {
|
||||
ss[node.ServiceId] = node
|
||||
if ssts, ok := sst[node.ServiceType]; !ok {
|
||||
if _, ok := sst[node.ServiceType]; !ok {
|
||||
sst[node.ServiceType] = make([]*ServiceNode, 0)
|
||||
sst[node.ServiceType] = append(sst[node.ServiceType], node)
|
||||
} else {
|
||||
ssts = append(ssts, node)
|
||||
sst[node.ServiceType] = append(sst[node.ServiceType], node)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user