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

Function main

examples/route_guide/client/client.go:154–194  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

152}
153
154func main() {
155 flag.Parse()
156 var opts []grpc.DialOption
157 if *tls {
158 if *caFile == "" {
159 *caFile = data.Path("x509/ca_cert.pem")
160 }
161 creds, err := credentials.NewClientTLSFromFile(*caFile, *serverHostOverride)
162 if err != nil {
163 log.Fatalf("Failed to create TLS credentials: %v", err)
164 }
165 opts = append(opts, grpc.WithTransportCredentials(creds))
166 } else {
167 opts = append(opts, grpc.WithTransportCredentials(insecure.NewCredentials()))
168 }
169
170 conn, err := grpc.NewClient(*serverAddr, opts...)
171 if err != nil {
172 log.Fatalf("fail to dial: %v", err)
173 }
174 defer conn.Close()
175 client := pb.NewRouteGuideClient(conn)
176
177 // Looking for a valid feature
178 printFeature(client, &pb.Point{Latitude: 409146138, Longitude: -746188906})
179
180 // Feature missing.
181 printFeature(client, &pb.Point{Latitude: 0, Longitude: 0})
182
183 // Looking for features between 40, -75 and 42, -73.
184 printFeatures(client, &pb.Rectangle{
185 Lo: &pb.Point{Latitude: 400000000, Longitude: -750000000},
186 Hi: &pb.Point{Latitude: 420000000, Longitude: -730000000},
187 })
188
189 // RecordRoute
190 runRecordRoute(client)
191
192 // RouteChat
193 runRouteChat(client)
194}

Callers

nothing calls this directly

Calls 12

PathFunction · 0.92
NewClientTLSFromFileFunction · 0.92
WithTransportCredentialsFunction · 0.92
NewCredentialsFunction · 0.92
NewClientFunction · 0.92
printFeatureFunction · 0.85
printFeaturesFunction · 0.85
runRecordRouteFunction · 0.85
runRouteChatFunction · 0.85
ParseMethod · 0.65
FatalfMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected