functional/rpcpb/member.go
func (m *Member) DialEtcdGRPCServer(opts ...grpc.DialOption) (*grpc.ClientConn, error) {
	dialOpts := []grpc.DialOption{
		grpc.WithTimeout(5 * time.Second),
		grpc.WithBlock(),
	}

	secure := false
	for _, cu := range m.Etcd.AdvertiseClientURLs {
		u, err := url.Parse(cu)
		if err != nil {
			return nil, err
		}
		if u.Scheme == "https" { // TODO: handle unix
			secure = true
		}
	}

	if secure {
		// assume save TLS assets are already stord on disk
		tlsInfo := transport.TLSInfo{
			CertFile:      m.ClientCertPath,
			KeyFile:       m.ClientKeyPath,
			TrustedCAFile: m.ClientTrustedCAPath,

			// TODO: remove this with generated certs
			// only need it for auto TLS
			InsecureSkipVerify: true,
		}
		tlsConfig, err := tlsInfo.ClientConfig()
		if err != nil {
			return nil, err
		}
		creds := credentials.NewTLS(tlsConfig)
		dialOpts = append(dialOpts, grpc.WithTransportCredentials(creds))
	} else {
		dialOpts = append(dialOpts, grpc.WithInsecure())
	}
	dialOpts = append(dialOpts, opts...)
	return grpc.Dial(m.EtcdClientEndpoint, dialOpts...)
}
func (m *Member) DialEtcdGRPCServer(opts ...grpc.DialOption) (*grpc.ClientConn, error) {
	dialOpts := []grpc.DialOption{
		grpc.WithTimeout(5 * time.Second),
		grpc.WithBlock(),
	}

	secure := false
	for _, cu := range m.Etcd.AdvertiseClientURLs {
		u, err := url.Parse(cu)
		if err != nil {
			return nil, err
		}
		if u.Scheme == "https" { // TODO: handle unix
			secure = true
		}
	}

	if secure {
		// assume save TLS assets are already stord on disk
		tlsInfo := transport.TLSInfo{
			CertFile:      m.ClientCertPath,
			KeyFile:       m.ClientKeyPath,
			TrustedCAFile: m.ClientTrustedCAPath,

			// TODO: remove this with generated certs
			// only need it for auto TLS
			InsecureSkipVerify: true,
		}
		tlsConfig, err := tlsInfo.ClientConfig()
		if err != nil {
			return nil, err
		}
		creds := credentials.NewTLS(tlsConfig)
		dialOpts = append(dialOpts, grpc.WithTransportCredentials(creds))
	} else {
		dialOpts = append(dialOpts, grpc.WithInsecure())
	}
	dialOpts = append(dialOpts, opts...)
	return grpc.Dial(m.EtcdClientEndpoint, dialOpts...)
}
func ( m * Member ) DialEtcdGRPCServer ( opts ... grpc . DialOption ) ( * grpc . ClientConn , error ) { dialOpts := [ ] grpc . DialOption { grpc . WithTimeout ( 5 * time . Second ) , grpc . WithBlock ( ) , } secure := false for _ , cu := range m . Etcd . AdvertiseClientURLs { u , err := url . Parse ( cu ) if err != nil { return nil , err } if u . Scheme == " " { // TODO: handle unix secure = true } } if secure { // assume save TLS assets are already stord on disk tlsInfo := transport . TLSInfo { CertFile : m . ClientCertPath , KeyFile : m . ClientKeyPath , TrustedCAFile : m . ClientTrustedCAPath , // TODO: remove this with generated certs // only need it for auto TLS InsecureSkipVerify : true , } tlsConfig , err := tlsInfo . ClientConfig ( ) if err != nil { return nil , err } creds := credentials . NewTLS ( tlsConfig ) dialOpts = append ( dialOpts , grpc . WithTransportCredentials ( creds ) ) } else { dialOpts = append ( dialOpts , grpc . WithInsecure ( ) ) } dialOpts = append ( dialOpts , opts ... ) return grpc . Dial ( m . EtcdClientEndpoint , dialOpts ... ) }
// DialEtcdGRPCServer creates a raw gRPC connection to an etcd member.
DialEtcdGRPCServer creates a raw gRPC connection to an etcd member .