-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Consider deprecating Dial and DialContext and replacing with a NewClient #1786
Comments
Could you elaborate on what passthrough would be? Wouldn't all Dial's use a DNS resolver? |
Passthrough sends the entire target string (after "passthrough:///") to the dialer as the address, verbatim. A DNS resolver would resolve the target (after "dns:///"), turn it into IP addresses & ports, and those would be handed to the dialer. It just so happens that the default dialer ( However, this passthrough method means we can't do things like load-balance across all the DNS results for that name. You can see more about the resolver/balancer design in the gRFC here: https://github.com/grpc/proposal/blob/master/L9-go-resolver-balancer-API.md |
Hello guys, I notice that the conn, err := grpc.DialContext(
context.Background(), "bufnet",
grpc.WithContextDialer(
func(context.Context, string) (net.Conn, error) {
return s.lis.Dial()
},
),
grpc.WithTransportCredentials(insecure.NewCredentials()),
)
// then create the client using the new conn
client := someservice.NewSomeServiceClient(conn) I tried replacing conn, err := grpc.NewClient(
"passthrough", // ?
grpc.WithContextDialer(
func(context.Context, string) (net.Conn, error) {
return s.lis.Dial()
},
),
grpc.WithTransportCredentials(insecure.NewCredentials()),
) But now i get a DNS error on RPC call from the client : Can you please tell me where there is a doc to properly transition this use case ? thanks |
Hi @raphoester, in case you are still having this issue I solve it by setting // set the default resolver schema to "passthrough" to prevent DNS resolution
// issues while testing; the default scheme used by grpc.NewClient is "dns".
func init() {
resolver.SetDefaultScheme("passthrough")
} This way you can prevent the DNS issues when replacing withDialer := func(l *bufconn.Listener) gRPC.DialOption {
return gRPC.WithContextDialer(func(context.Context, string) (net.Conn, error) {
return l.Dial()
})
} |
This should work: conn, err := grpc.NewClient(
"passthrough:whatever",
grpc.WithContextDialer(
func(context.Context, string) (net.Conn, error) {
return s.lis.Dial()
},
),
grpc.WithTransportCredentials(insecure.NewCredentials()),
) I don't know why, but https://github.com/grpc/grpc/blob/master/doc/naming.md doesn't describe |
This is because |
I wonder how other implementations deal with cases where you don't want dns resolution at all. I.e. when you use a dialer that does something special like opening an in-memory pipe to a server.
I think this makes sense. I also like that |
The other languages have a real in-memory transport that they support. I believe C++ uses a separate resolver, and Java uses a completely different channel builder (i.e. they don't pass a target string at all). For Go, I'd love to one day add support for other transports besides HTTP/2 (#906). An "inmemory" transport would come with an "inmemory" resolver that you'd specify as the scheme for the channel and emit a single "inmemory" address to connect to. The |
For anyone who might need something like this - I have this implementation. It's a |
Following manual [0] updating grpc-go version on all relevant files. This version bump is required in order to address grpc function deprecations introduced in grpc-go v1.64.0 [1]. [0] https://github.com/kubevirt/kubevirt/blob/main/docs/updating-dependencies.md [1] grpc/grpc-go#1786 Signed-off-by: Adi Aloni <[email protected]>
Following manual [0] updating grpc-go version on all relevant files. This version bump is required in order to address grpc function deprecations introduced in grpc-go v1.64.0 [1]. [0] https://github.com/kubevirt/kubevirt/blob/main/docs/updating-dependencies.md [1] grpc/grpc-go#1786 Signed-off-by: Adi Aloni <[email protected]>
Is this change compatible with forward-proxies? What is the best to change the behaviour back? |
@puneet-traceable can you file a new issue for this please? |
Filed a new one #7556 |
Dial
andDialContext
have several differences from how gRPC works in other languages. ANewClient
function that works more like other languages would differ in at least two ways:If we create a
NewClient
, we'd probably also want to make matchingClientOptions
instead ofDialOptions
, as someDialOptions
(e.g.WithBlock
orWithTimeout
) do not make sense when not dialing synchronously.The text was updated successfully, but these errors were encountered: