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:
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.
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
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