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

Function makeCaller

benchmark/client/main.go:174–195  ·  view source on GitHub ↗
(cc *grpc.ClientConn, req *testpb.SimpleRequest)

Source from the content-addressed store, hash-verified

172}
173
174func makeCaller(cc *grpc.ClientConn, req *testpb.SimpleRequest) func() {
175 client := testgrpc.NewBenchmarkServiceClient(cc)
176 if *rpcType == "unary" {
177 return func() {
178 if _, err := client.UnaryCall(context.Background(), req); err != nil {
179 logger.Fatalf("RPC failed: %v", err)
180 }
181 }
182 }
183 stream, err := client.StreamingCall(context.Background())
184 if err != nil {
185 logger.Fatalf("RPC failed: %v", err)
186 }
187 return func() {
188 if err := stream.Send(req); err != nil {
189 logger.Fatalf("Streaming RPC failed to send: %v", err)
190 }
191 if _, err := stream.Recv(); err != nil {
192 logger.Fatalf("Streaming RPC failed to read: %v", err)
193 }
194 }
195}
196
197func parseHist(hist *stats.Histogram) {
198 fmt.Println("qps:", float64(hist.Count)/float64(*duration))

Callers 1

runWithConnFunction · 0.85

Calls 5

UnaryCallMethod · 0.95
StreamingCallMethod · 0.95
FatalfMethod · 0.65
SendMethod · 0.65
RecvMethod · 0.65

Tested by

no test coverage detected