MCPcopy
hub / github.com/grpc/grpc-go / hashKey

Function hashKey

balancer/ringhash/ringhash.go:112–119  ·  view source on GitHub ↗

hashKey returns the hash key to use for an endpoint. Per gRFC A61, each entry in the ring is a hash of the endpoint's hash key concatenated with a per-entry unique suffix.

(endpoint resolver.Endpoint)

Source from the content-addressed store, hash-verified

110// in the ring is a hash of the endpoint's hash key concatenated with a
111// per-entry unique suffix.
112func hashKey(endpoint resolver.Endpoint) string {
113 if hk := ringhash.HashKey(endpoint); hk != "" {
114 return hk
115 }
116 // If no hash key is set, use the endpoint's first address as the hash key.
117 // This is the default behavior when no hash key is set.
118 return endpoint.Addresses[0].Addr
119}
120
121// UpdateState intercepts child balancer state updates. It updates the
122// per-endpoint state stored in the ring, and also the aggregated state based on

Callers 2

TestRingNewMethod · 0.85
UpdateStateMethod · 0.85

Calls 1

HashKeyFunction · 0.92

Tested by 1

TestRingNewMethod · 0.68