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

Function getWeightAttribute

balancer/ringhash/ringhash.go:387–393  ·  view source on GitHub ↗

getWeightAttribute is a convenience function which returns the value of the weight endpoint Attribute. When used in the xDS context, the weight attribute is guaranteed to be non-zero. But, when used in a non-xDS context, the weight attribute could be unset. A Default of 1 is used in the latter case

(e resolver.Endpoint)

Source from the content-addressed store, hash-verified

385// non-zero. But, when used in a non-xDS context, the weight attribute could be
386// unset. A Default of 1 is used in the latter case.
387func getWeightAttribute(e resolver.Endpoint) uint32 {
388 w := weight.FromEndpoint(e).Weight
389 if w == 0 {
390 return 1
391 }
392 return w
393}
394
395type endpointState struct {
396 // hashKey is the hash key of the endpoint. Per gRFC A61, each entry in the

Callers 2

TestRingNewMethod · 0.85
UpdateStateMethod · 0.85

Calls 1

FromEndpointFunction · 0.92

Tested by 1

TestRingNewMethod · 0.68