Skip to content
This repository has been archived by the owner on Jan 6, 2020. It is now read-only.

grpc.WithBalancer is deprecated #1

Open
luigi-riefolo opened this issue Nov 21, 2017 · 2 comments
Open

grpc.WithBalancer is deprecated #1

luigi-riefolo opened this issue Nov 21, 2017 · 2 comments

Comments

@luigi-riefolo
Copy link

WithBalancer returns a DialOption which sets a load balancer with the v1 API. Name resolver will be ignored if this DialOption is specified. Deprecated: use the new balancer APIs in balancer package instead.

Would it be possible to provide an example with grpc.Balancer ?

@olivere
Copy link
Owner

olivere commented Nov 25, 2017

I see. Hmm, I have to dig into the changes and that'll take a while.

@olivere
Copy link
Owner

olivere commented Nov 25, 2017

I think this repository needs to be deprecated with the new Balancer API v2. If I read the proposal correctly, we need to significantly change the resolver.

Instead of

grpc.Dial(targetName, grpc.WithBalancer(grpc.Roundrobin(userCustomResolver())))

you now need pre-register e.g. the Consul resolver, then do something like this:

resolver.Register(newConsulResolver())
balancer.Register(newRoundRobin())
grpc.Dial(targetName)

We need to register e.g. our resolver with a scheme of consul, which gets registered by importing a package (just like SQL drivers are registered into database/sql when you import them). Then the scheme is used to pick the correct resolver on Dial.

I think it would be better to keep using Balancer API v1 (which has a wrapper for the new v2), then create new repositories for e.g. a Consul-based resolver implementation for v2.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants