MCPcopy
hub / github.com/grpc/grpc-go / createTestConn

Function createTestConn

interop/grpclb_fallback/client_linux.go:97–120  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

95}
96
97func createTestConn() *grpc.ClientConn {
98 opts := []grpc.DialOption{
99 grpc.WithContextDialer(dialTCPUserTimeout),
100 }
101 switch *customCredentialsType {
102 case "tls":
103 creds := credentials.NewClientTLSFromCert(nil, "")
104 opts = append(opts, grpc.WithTransportCredentials(creds))
105 case "alts":
106 creds := alts.NewClientCreds(alts.DefaultClientOptions())
107 opts = append(opts, grpc.WithTransportCredentials(creds))
108 case "google_default_credentials":
109 opts = append(opts, grpc.WithCredentialsBundle(google.NewDefaultCredentials()))
110 case "compute_engine_channel_creds":
111 opts = append(opts, grpc.WithCredentialsBundle(google.NewComputeEngineCredentials()))
112 default:
113 errorLog.Fatalf("Invalid --custom_credentials_type:%v", *customCredentialsType)
114 }
115 conn, err := grpc.NewClient(*serverURI, opts...)
116 if err != nil {
117 errorLog.Fatalf("grpc.NewClient(%q) = %v", *serverURI, err)
118 }
119 return conn
120}
121
122func runCmd(command string) {
123 infoLog.Printf("Running cmd:|%v|\n", command)

Callers 2

doFallbackBeforeStartupFunction · 0.85
doFallbackAfterStartupFunction · 0.85

Calls 10

WithContextDialerFunction · 0.92
NewClientTLSFromCertFunction · 0.92
WithTransportCredentialsFunction · 0.92
NewClientCredsFunction · 0.92
DefaultClientOptionsFunction · 0.92
WithCredentialsBundleFunction · 0.92
NewDefaultCredentialsFunction · 0.92
NewClientFunction · 0.92
FatalfMethod · 0.65

Tested by

no test coverage detected