(args *testpb.StreamingOutputCallRequest, stream testgrpc.TestService_StreamingOutputCallServer)
| 255 | } |
| 256 | |
| 257 | func (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 | |
| 288 | func (s *testServer) StreamingInputCall(stream testgrpc.TestService_StreamingInputCallServer) error { |
| 289 | var sum int |
nothing calls this directly
no test coverage detected