Alanxtl commented on code in PR #3864:
URL: https://github.com/apache/dubbo-go/pull/3864#discussion_r4661247967
##########
cluster/loadbalance/consistenthashing/loadbalance.go:
##########
@@ -89,3 +80,15 @@ func (lb *conshashLoadBalance) Select(invokers
[]base.Invoker, invocation base.I
}
return selector.Select(invocation)
}
+
+// invokersHashCode identifies the invoker list a selector was built from, so
the ring is rebuilt
+// whenever the list changes. Like the Java implementation it goes by invoker
identity: the invoker
+// types keep their state in unexported fields, so encoding them (with
encoding/json, say) gives
+// "{}" for every invoker and only tells lists of different lengths apart.
+func invokersHashCode(invokers []base.Invoker) uint32 {
+ h := crc32.NewIEEE()
+ for _, invoker := range invokers {
+ _, _ = fmt.Fprintf(h, "%p;", invoker)
+ }
+ return h.Sum32()
+}
Review Comment:
no need to warp a seperate func, just inline it in the line 66
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]