feat: change consistent hashing element name (#1652)
Signed-off-by: Gaius <gaius.qi@gmail.com>
This commit is contained in:
parent
1ed015c222
commit
f129623c2f
|
|
@ -18,6 +18,7 @@ package balancer
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"google.golang.org/grpc/balancer"
|
"google.golang.org/grpc/balancer"
|
||||||
"google.golang.org/grpc/balancer/base"
|
"google.golang.org/grpc/balancer/base"
|
||||||
|
|
@ -63,7 +64,7 @@ func (b *consistentHashingPickerBuilder) Build(info base.PickerBuildInfo) balanc
|
||||||
hashring := consistent.New()
|
hashring := consistent.New()
|
||||||
scs := make(map[string]balancer.SubConn, len(info.ReadySCs))
|
scs := make(map[string]balancer.SubConn, len(info.ReadySCs))
|
||||||
for sc, scInfo := range 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)
|
hashring.Add(element)
|
||||||
scs[element] = sc
|
scs[element] = sc
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue