Coder Social home page Coder Social logo

Comments (5)

dfawley avatar dfawley commented on July 1, 2024 3

You can specify the passthrough resolver by using "passthrough:///bufnet" as your target instead (and actually buffnet is arbitrary; you could put anything there instead, or probably omit it entirely).

Or you can globally make the default resolver "passthrough" by using https://pkg.go.dev/google.golang.org/grpc/resolver#SetDefaultScheme -- I do not recommend this approach, though, as "passthrough" has some negative properties and really only exists for backward compatibility reasons.

You can also feel free to keep using Dial; it is not going anywhere. We don't recommend its use, but we will continue to support it for all 1.x releases (and no 2.x release is being considered).

Ideally we will eventually add support for an "in-memory" transport for your exact use case. However, that does not currently exist. That would probably require something like #906 which we just don't have the resources to prioritize.

from grpc-go.

SLoeuillet avatar SLoeuillet commented on July 1, 2024

Default resolver is now dns with NewClient, was passthrough
I suppose you'll have to force passthrough resolver

With WithResolvers ?

from grpc-go.

SLoeuillet avatar SLoeuillet commented on July 1, 2024

From DialContext 1.63.0 doc :

One subtle difference between NewClient and Dial and DialContext is that the former uses "dns" as the default name resolver, while the latter use "passthrough" for backward compatibility. This distinction should not matter to most users, but could matter to legacy users that specify a custom dialer and expect it to receive the target string directly.

from grpc-go.

gnuletik avatar gnuletik commented on July 1, 2024

Thanks for the feedback @SLoeuillet!

I've gave a check to WithResolvers() (which is experimental). It expects a resolver.Builder.

Ideally, I'd pass a passthrough's Builder in order to get the original behavior.
But the passthrough package is only available behind an internal/ directory, so I can't import it:

package passthrough
import _ "google.golang.org/grpc/internal/resolver/passthrough" // import for side effects after package was moved

Initially, I also checked if I could set the defaultScheme to passthrough (that's what grpc.DialContext does now).
But the field and the setter are are not exported either.

grpc-go/dialoptions.go

Lines 662 to 668 in c68f456

// withDefaultScheme is used to allow Dial to use "passthrough" as the default
// name resolver, while NewClient uses "dns" otherwise.
func withDefaultScheme(s string) DialOption {
return newFuncDialOption(func(o *dialOptions) {
o.defaultScheme = s
})
}

The only workaround I think of would be to copy the passthrough implementation, so I can pass it to WithResolvers() but that seems counter-intuitive.

As of now, in order to upgrade grpc-go to v1.63.0, I think the best way is to keep using the deprecated grpc.DialContext() function.

Is it intended by the grpc-go developer team? Is there an alternative?

Thanks!

from grpc-go.

gnuletik avatar gnuletik commented on July 1, 2024

Oh awesome! It works like a charm!
Thanks a lot!

from grpc-go.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.