Grpc-go: Consider deprecating Dial and DialContext and replacing with a NewClient

Created on 8 Jan 2018  路  2Comments  路  Source: grpc/grpc-go

Dial and DialContext have several differences from how gRPC works in other languages. A NewClient function that works more like other languages would differ in at least two ways:

  1. Default to DNS resolver instead of passthrough.
  2. Make target compliant with RFC 3986 (#1911).
  3. Start IDLE instead of CONNECTING.

If we create a NewClient, we'd probably also want to make matching ClientOptions instead of DialOptions, as some DialOptions (e.g. WithBlock or WithTimeout) do not make sense when not dialing synchronously.

P2 API Change

Most helpful comment

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 (net.Dial) is able to do DNS name resolution, and so passing "google.com:22" will work just fine with it.

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

All 2 comments

Default to DNS resolver instead of passthrough.

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 (net.Dial) is able to do DNS name resolution, and so passing "google.com:22" will work just fine with it.

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

Was this page helpful?
0 / 5 - 0 ratings