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

Method StreamingOutputCall

test/end2end_test.go:257–286  ·  view source on GitHub ↗
(args *testpb.StreamingOutputCallRequest, stream testgrpc.TestService_StreamingOutputCallServer)

Source from the content-addressed store, hash-verified

255}
256
257func (s *testServer) StreamingOutputCall(args *testpb.StreamingOutputCallRequest, stream testgrpc.TestService_StreamingOutputCallServer) error {
258 if md, ok := metadata.FromIncomingContext(stream.Context()); ok {
259 if _, exists := md[":authority"]; !exists {
260 return status.Errorf(codes.DataLoss, "expected an :authority metadata: %v", md)
261 }
262 // For testing purpose, returns an error if user-agent is failAppUA.
263 // To test that client gets the correct error.
264 if ua, ok := md["user-agent"]; !ok || strings.HasPrefix(ua[0], failAppUA) {
265 return status.Error(codes.DataLoss, "error for testing: "+failAppUA)
266 }
267 }
268 cs := args.GetResponseParameters()
269 for _, c := range cs {
270 if us := c.GetIntervalUs(); us > 0 {
271 time.Sleep(time.Duration(us) * time.Microsecond)
272 }
273
274 payload, err := newPayload(args.GetResponseType(), c.GetSize())
275 if err != nil {
276 return err
277 }
278
279 if err := stream.Send(&testpb.StreamingOutputCallResponse{
280 Payload: payload,
281 }); err != nil {
282 return err
283 }
284 }
285 return nil
286}
287
288func (s *testServer) StreamingInputCall(stream testgrpc.TestService_StreamingInputCallServer) error {
289 var sum int

Callers

nothing calls this directly

Calls 10

FromIncomingContextFunction · 0.92
newPayloadFunction · 0.85
GetResponseParametersMethod · 0.80
GetIntervalUsMethod · 0.80
GetSizeMethod · 0.80
ContextMethod · 0.65
ErrorfMethod · 0.65
ErrorMethod · 0.65
SendMethod · 0.65
GetResponseTypeMethod · 0.45

Tested by

no test coverage detected