From f129623c2f1d58caba39e0bbfb16e252f7222721 Mon Sep 17 00:00:00 2001 From: Gaius Date: Tue, 6 Sep 2022 21:26:01 +0800 Subject: [PATCH] feat: change consistent hashing element name (#1652) Signed-off-by: Gaius --- pkg/balancer/consistent_hashing.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/balancer/consistent_hashing.go b/pkg/balancer/consistent_hashing.go index 8fa724d51..7f9120c64 100644 --- a/pkg/balancer/consistent_hashing.go +++ b/pkg/balancer/consistent_hashing.go @@ -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 }