I'm attempting to upgrade from v1.29.0, and I noticed from #3431 that several experimental APIs have been overhauled.
My code used to look like the following:
resolver, err := naming.NewDNSResolverWithFreq(5 * time.Second)
if err != nil {
// ...
}
conn, err := grpc.Dial(
target,
tlsOption,
grpc.WithBalancer(grpc.RoundRobin(resolver)),
)
if err != nil {
// ...
}
client := pb.NewFooServiceClient(conn)
What is the correct way to rewrite this code with v1.31.0? I spent a good deal of time trying to figure out how to fix my code, but due to #3811 , and due to some APIs being now, it seems, fundamentally different, I'm really unsure if I'm doing it right.
Please can you show me how to correctly rewrite the above code to use a round robin DNS resolver in v1.31.0?
Thanks
Prepending dns:/// to target tells the client to use a DNS resolver.
The default load balancer is pick_first. To set it to round_robin, use dial option
grpc.WithDefaultServiceConfig(`{"loadBalancingPolicy":"round_robin"}`)
Examples: https://github.com/grpc/grpc-go/tree/master/examples/features/load_balancing
@menghanl thanks. please note that the examples are building against v1.30.0. Some methods are deprecated
Yes, thanks for notifying. I'm working on a fix.
I will close this issue, and track the examples in #3811