Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to correctly configure the load balancer in v1.31.0? #3812

Closed
vibridi opened this issue Aug 13, 2020 · 3 comments
Closed

How to correctly configure the load balancer in v1.31.0? #3812

vibridi opened this issue Aug 13, 2020 · 3 comments

Comments

@vibridi
Copy link

vibridi commented Aug 13, 2020

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

@menghanl
Copy link
Contributor

menghanl commented Aug 13, 2020

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

@vibridi
Copy link
Author

vibridi commented Aug 13, 2020

@menghanl thanks. please note that the examples are building against v1.30.0. Some methods are deprecated

@menghanl
Copy link
Contributor

Yes, thanks for notifying. I'm working on a fix.

I will close this issue, and track the examples in #3811

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants