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)
| 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. |
| 387 | func getWeightAttribute(e resolver.Endpoint) uint32 { |
| 388 | w := weight.FromEndpoint(e).Weight |
| 389 | if w == 0 { |
| 390 | return 1 |
| 391 | } |
| 392 | return w |
| 393 | } |
| 394 | |
| 395 | type endpointState struct { |
| 396 | // hashKey is the hash key of the endpoint. Per gRFC A61, each entry in the |