0z5a commented on code in PR #3864:
URL: https://github.com/apache/dubbo-go/pull/3864#discussion_r4664728472


##########
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:
   Done in b5a4249: the identity hash is now computed inline in `Select` and 
the helper is gone. No behaviour change; the consistent-hash tests pass before 
and after (10/10), the new commit also passes with `-race`, and `go vet` is 
clean. Thanks!
   



-- 
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]

Reply via email to