Register registers the balancer builder to the balancer map. b.Name will be used as the name registered with this builder. If the Builder implements ConfigParser, ParseConfig will be called when new service configs are received by the resolver, and the result will be provided to the Balancer in Upda
(b Builder)
| 56 | // an init() function), and is not thread-safe. If multiple Balancers are |
| 57 | // registered with the same name, the one registered last will take effect. |
| 58 | func Register(b Builder) { |
| 59 | name := b.Name() |
| 60 | if !envconfig.CaseSensitiveBalancerRegistries { |
| 61 | name = strings.ToLower(name) |
| 62 | if name != b.Name() { |
| 63 | logger.Warningf("Balancer registered with name %q. grpc-go has switched to case sensitive balancer registries. GRPC_GO_EXPERIMENTAL_CASE_SENSITIVE_BALANCER_REGISTRIES env variable will be removed in release v1.82.0", b.Name()) |
| 64 | } |
| 65 | } |
| 66 | m[name] = b |
| 67 | } |
| 68 | |
| 69 | // unregisterForTesting deletes the balancer with the given name from the |
| 70 | // balancer map. |