feat: change consistent hashing element name (#1652)

Signed-off-by: Gaius <gaius.qi@gmail.com>
This commit is contained in:
Gaius 2022-09-06 21:26:01 +08:00
parent 1ed015c222
commit f129623c2f
No known key found for this signature in database
GPG Key ID: 8B4E5D1290FA2FFB
1 changed files with 2 additions and 1 deletions

View File

@ -18,6 +18,7 @@ package balancer
import (
"errors"
"fmt"
"google.golang.org/grpc/balancer"
"google.golang.org/grpc/balancer/base"
@ -63,7 +64,7 @@ func (b *consistentHashingPickerBuilder) Build(info base.PickerBuildInfo) balanc
hashring := consistent.New()
scs := make(map[string]balancer.SubConn, len(info.ReadySCs))
for sc, scInfo := range info.ReadySCs {
element := scInfo.Address.Addr + scInfo.Address.ServerName
element := fmt.Sprintf("%s:%s", scInfo.Address.Addr, scInfo.Address.ServerName)
hashring.Add(element)
scs[element] = sc
}