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

Method doFullDuplexCallRoundtrip

binarylog/binarylog_end2end_test.go:317–364  ·  view source on GitHub ↗
(c *rpcConfig)

Source from the content-addressed store, hash-verified

315}
316
317func (te *test) doFullDuplexCallRoundtrip(c *rpcConfig) ([]proto.Message, []proto.Message, error) {
318 var (
319 reqs []proto.Message
320 resps []proto.Message
321 err error
322 )
323 tc := testgrpc.NewTestServiceClient(te.ss.CC)
324 ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
325 defer cancel()
326 ctx = metadata.NewOutgoingContext(ctx, testMetadata)
327
328 stream, err := tc.FullDuplexCall(ctx)
329 if err != nil {
330 return reqs, resps, err
331 }
332
333 if c.callType == cancelRPC {
334 cancel()
335 return reqs, resps, context.Canceled
336 }
337
338 var startID int32
339 if !c.success {
340 startID = errorID
341 }
342 for i := 0; i < c.count; i++ {
343 req := &testpb.StreamingOutputCallRequest{
344 Payload: idToPayload(int32(i) + startID),
345 }
346 reqs = append(reqs, req)
347 if err = stream.Send(req); err != nil {
348 return reqs, resps, err
349 }
350 var resp *testpb.StreamingOutputCallResponse
351 if resp, err = stream.Recv(); err != nil {
352 return reqs, resps, err
353 }
354 resps = append(resps, resp)
355 }
356 if err = stream.CloseSend(); err != nil && err != io.EOF {
357 return reqs, resps, err
358 }
359 if _, err = stream.Recv(); err != io.EOF {
360 return reqs, resps, err
361 }
362
363 return reqs, resps, nil
364}
365
366func (te *test) doClientStreamCall(c *rpcConfig) ([]proto.Message, proto.Message, error) {
367 var (

Callers 1

runRPCsFunction · 0.45

Calls 6

FullDuplexCallMethod · 0.95
NewOutgoingContextFunction · 0.92
idToPayloadFunction · 0.70
SendMethod · 0.65
RecvMethod · 0.65
CloseSendMethod · 0.65

Tested by

no test coverage detected