The :authority pseudo-header for a gRPC Client defaults to the host
portion of the dialed target and can only be overwritten by providing a
TransportCredentials. However, there are cases where setting this header
independent of any tranport security is valid. In my particular case,
in order to leverage Envoy for request routing, the cluster/service name
must be provided in the :authority header. This may also be useful in a
testing context.
This patch adds a DialOption to overwrite the authority header,
even if TransportCredentials are provided (I'd imagine you'd only ever
need to specify one or the other).
* Add the initial service config support
* start scWatcher later
* remove timeoutCh
* address the comments
* deal with dial timeout
* defer cancel for the newly created context for correct lifetime management
* fix the defer order
* added other 2 missing cancels
Prior to this change, it was possible for `DialContext` to return
`(nil, err)` without properly closing the `ClientConn`, resulting in an
unavoidable leak of the `resetAddrConn` goroutine.
Previously, cancellation of the context would cause these transient
errors to be swallowed since the function would return before the
log line was reached.
This is a minor breaking change to `TransportCredentials`, however
it should not be a problem in practice as not many users are using
custom implementations. In particular, users of `NewTLS` will not
be affected.
This change also replaces the earlier `Timeout` and `Cancel` fields
with a `context.Context`, which is plumbed all the way down from
`grpc.Dial`, laying the ground work for a user-provided context.
Also, support for Go 1.7 is added.
When goaway is received by client, a new ac should replace the old ac.
Without this change, ac is removed first and a new one is added later,
ac.tearDown() and cc.newAddrConn are two functions called consecutively,
So there's a small chance that getTransport is called in between and
misses the new ac. After this change, the value in map conns is replaced
directly, and this issue should be resolved.