This commit is contained in:
iamqizhao 2015-03-04 11:15:10 -08:00
Родитель b052a1255f
Коммит c73e40b804
4 изменённых файлов: 8 добавлений и 9 удалений

Просмотреть файл

@ -75,8 +75,7 @@ func WithPerRPCCredentials(creds credentials.Credentials) DialOption {
}
}
// WithTimeout returns a DialOption which configures a timeout for dialing a
// client connection.
// WithTimeout returns a DialOption that configures a timeout for dialing a client connection.
func WithTimeout(d time.Duration) DialOption {
return func(o *transport.DialOptions) {
o.Timeout = d
@ -150,7 +149,7 @@ func (cc *ClientConn) resetTransport(closeTransport bool) error {
return ErrClientConnTimeout
}
}
newTransport, err := transport.NewClientTransport(cc.target, dopts)
newTransport, err := transport.NewClientTransport(cc.target, &dopts)
if err != nil {
if netErr, ok := err.(net.Error); ok && netErr.Timeout() {
cc.Close()
@ -194,7 +193,7 @@ func (cc *ClientConn) transportMonitor() {
if err := cc.resetTransport(true); err != nil {
// The channel is closing.
// TODO(zhaoq): Record the error with glog.V.
log.Printf("grpc: transport exits due to %v", err)
log.Printf("grpc: ClientConn.transportMonitor exits due to: %v", err)
return
}
continue

Просмотреть файл

@ -96,7 +96,7 @@ type http2Client struct {
// newHTTP2Client constructs a connected ClientTransport to addr based on HTTP2
// and starts to receive messages on it. Non-nil error returns if construction
// fails.
func newHTTP2Client(addr string, opts DialOptions) (_ ClientTransport, err error) {
func newHTTP2Client(addr string, opts *DialOptions) (_ ClientTransport, err error) {
var (
connErr error
conn net.Conn

Просмотреть файл

@ -311,7 +311,7 @@ func NewServerTransport(protocol string, conn net.Conn, maxStreams uint32) (Serv
return newHTTP2Server(conn, maxStreams)
}
// DialOptions covers all relevant options for dial a client connection.
// DialOptions covers all relevant options for dialing a server.
type DialOptions struct {
Protocol string
AuthOptions []credentials.Credentials
@ -320,7 +320,7 @@ type DialOptions struct {
// NewClientTransport establishes the transport with the required DialOptions
// and returns it to the caller.
func NewClientTransport(target string, opts DialOptions) (ClientTransport, error) {
func NewClientTransport(target string, opts *DialOptions) (ClientTransport, error) {
return newHTTP2Client(target, opts)
}

Просмотреть файл

@ -184,9 +184,9 @@ func setUp(t *testing.T, useTLS bool, port int, maxStreams uint32, suspend bool)
dopts := DialOptions{
AuthOptions: []credentials.Credentials{creds},
}
ct, connErr = NewClientTransport(addr, dopts)
ct, connErr = NewClientTransport(addr, &dopts)
} else {
ct, connErr = NewClientTransport(addr, DialOptions{})
ct, connErr = NewClientTransport(addr, &DialOptions{})
}
if connErr != nil {
t.Fatalf("failed to create transport: %v", connErr)