It seems WithBalancerName is deprecated in https://github.com/grpc/grpc-go/pull/2900 in favor of WithDefaultServiceConfig. WithDefaultServiceConfig accepts only raw JSON, so if we want to use specific balancer statically, we need to use JSON to specify that.
Please keep WithBalancerName as is, or another way to specify the configurations instead of using JSON.
@dfawley How do you think of this? Not everyone use ServiceConfig with discovery, so it would be easier if we have another way to specify configs without specifying raw json.
The main reason to deprecate WithBalancerName is to avoid having two ways to do the same thing.
Reason for json is that it's the service config format agreed upon by all the grpc languages.
It is reasonable to support specifying service using a format other than json, maybe a native go struct.
For now, please try WithDefaultServiceConfig. To set balancer to roundrobin, you can set
grpc.WithDefaultServiceConfig(`{"loadBalancingPolicy":"round_robin"}`)
Accepting JSON config does not provide more backwards compatibility guarantees than accepting a config struct. Passing string configs like this is pretty weird, I would recommend code-first API, and if someone wants to drive the config from JSON or any other format, it can be done with a factory function, like ServiceConfigFromJSON() (which is still a poor API considering that there are many ways to source the JSON).
What's the status on this?
Most helpful comment
Accepting JSON config does not provide more backwards compatibility guarantees than accepting a config struct. Passing string configs like this is pretty weird, I would recommend code-first API, and if someone wants to drive the config from JSON or any other format, it can be done with a factory function, like ServiceConfigFromJSON() (which is still a poor API considering that there are many ways to source the JSON).