go-zero
go-zero copied to clipboard
consistenthash: map[uint64][]interface{}
When hash conflicts happened, the added item will be put into the []interface{}.
Supposing we have two different processes, which are watching the etcd events. While the two processes may add the services instances in different order:
p1: add n1, n2, n3 into the []interface{} p2: may add n3, n1, n2 into the []interface{}
If so, when we pick one from the []interface{}, p1 may choose index1 'n2', while p2 also choose index1 but it's 'n1'.
When using this library, the service may should pay attention to the order of instances (n1, n2, n3 or n3, n2, n1) returned by the service registry?
I don't think you need to pay attention. Balancing is random if not for consistent reason. If for consistent, you'll use keys, the order is not important.
This issue is stale because it has been open for 30 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.