// connect returns a Grpc |ClientConn| handle after successfully establishing
// a connection to the analyzer endpoint using |cc| config parameters.
//
// If |cc.EnableTLS| is false an insecure connection is used, and the remaining
// parameters or ignored, otherwise TLS is used.
//
// |cc.CAFile| is optional. If non-empty it should specify the path to a file
// containing a PEM encoding of root certificates to use for TLS.
//
// Logs and crashes on any grpc failure, and panics if |cc| is not set.
connect returns a Grpc |ClientConn| handle after successfully establishing
a connection to the analyzer endpoint using |cc| config parameters.

If |cc.EnableTLS| is false an insecure connection is used, and the remaining
parameters or ignored, otherwise TLS is used.

|cc.CAFile| is optional. If non-empty it should specify the path to a file
containing a PEM encoding of root certificates to use for TLS.

Logs and crashes on any grpc failure, and panics if |cc| is not set.
// connect returns a Grpc |ClientConn| handle after successfully establishing // a connection to the analyzer endpoint using |cc| config parameters . // // If |cc . EnableTLS| is false an insecure connection is used and the remaining // parameters or ignored otherwise TLS is used . // // |cc . CAFile| is optional . If non - empty it should specify the path to a file // containing a PEM encoding of root certificates to use for TLS . // // Logs and crashes on any grpc failure and panics if |cc| is not set .
func connect(cc *GrpcClientConfig) *grpc.ClientConn {
	if cc == nil {
		panic("Grpc client configuration is not set.")
	}
	glog.V(3).Infoln("Connecting to analyzer at:", cc.URL)
	var opts []grpc.DialOption
	if cc.EnableTLS {
		var creds credentials.TransportCredentials
		if cc.CAFile != "" {
			var err error
			creds, err = credentials.NewClientTLSFromFile(cc.CAFile, "")
			if err != nil {
				glog.Fatalf("Failed to create TLS credentials %v", err)
			}
		} else {
			creds = credentials.NewClientTLSFromCert(nil, "")
		}
		opts = append(opts, grpc.WithTransportCredentials(creds))
	} else {
		opts = append(opts, grpc.WithInsecure())
	}
	opts = append(opts, grpc.WithBlock())
	opts = append(opts, grpc.WithTimeout(cc.Timeout))
	glog.V(4).Infoln("Dialing", cc.URL, "...")
	conn, err := grpc.Dial(cc.URL, opts...)
	if err != nil {
		glog.Fatalf("Error in establishing connection to Analyzer [%v]: %v", cc.URL, err)
	}
	return conn
}
func connect ( cc * GrpcClientConfig ) * grpc . ClientConn { if cc == nil { panic ( " " ) } glog . V ( 3 ) . Infoln ( " " , cc . URL ) var opts [ ] grpc . DialOption if cc . EnableTLS { var creds credentials . TransportCredentials if cc . CAFile != " " { var err error creds , err = credentials . NewClientTLSFromFile ( cc . CAFile , " " ) if err != nil { glog . Fatalf ( " " , err ) } } else { creds = credentials . NewClientTLSFromCert ( nil , " " ) } opts = append ( opts , grpc . WithTransportCredentials ( creds ) ) } else { opts = append ( opts , grpc . WithInsecure ( ) ) } opts = append ( opts , grpc . WithBlock ( ) ) opts = append ( opts , grpc . WithTimeout ( cc . Timeout ) ) glog . V ( 4 ) . Infoln ( " " , cc . URL , " " ) conn , err := grpc . Dial ( cc . URL , opts ... ) if err != nil { glog . Fatalf ( " " , cc . URL , err ) } return conn }
connect returns a Grpc |ClientConn| handle after successfully establishing
a connection to the analyzer endpoint using |cc| config parameters.
connect returns a Grpc |ClientConn| handle after successfully establishing a connection to the analyzer endpoint using |cc| config parameters .