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

Method UnaryCall

interop/test_utils.go:727–754  ·  view source on GitHub ↗
(ctx context.Context, in *testpb.SimpleRequest)

Source from the content-addressed store, hash-verified

725}
726
727func (s *testServer) UnaryCall(ctx context.Context, in *testpb.SimpleRequest) (*testpb.SimpleResponse, error) {
728 st := in.GetResponseStatus()
729 if md, ok := metadata.FromIncomingContext(ctx); ok {
730 if initialMetadata, ok := md[initialMetadataKey]; ok {
731 header := metadata.Pairs(initialMetadataKey, initialMetadata[0])
732 grpc.SendHeader(ctx, header)
733 }
734 if trailingMetadata, ok := md[trailingMetadataKey]; ok {
735 trailer := metadata.Pairs(trailingMetadataKey, trailingMetadata[0])
736 grpc.SetTrailer(ctx, trailer)
737 }
738 }
739 if st != nil && st.Code != 0 {
740 return nil, status.Error(codes.Code(st.Code), st.Message)
741 }
742 pl, err := serverNewPayload(in.GetResponseType(), in.GetResponseSize())
743 if err != nil {
744 return nil, err
745 }
746 if r, orcaData := orca.CallMetricsRecorderFromContext(ctx), in.GetOrcaPerQueryReport(); r != nil && orcaData != nil {
747 // Transfer the request's per-Call ORCA data to the call metrics
748 // recorder in the context, if present.
749 setORCAMetrics(r, orcaData)
750 }
751 return &testpb.SimpleResponse{
752 Payload: pl,
753 }, nil
754}
755
756func setORCAMetrics(r orca.ServerMetricsRecorder, orcaData *testpb.TestOrcaReport) {
757 r.SetCPUUtilization(orcaData.CpuUtilization)

Callers

nothing calls this directly

Calls 13

FromIncomingContextFunction · 0.92
PairsFunction · 0.92
SendHeaderFunction · 0.92
SetTrailerFunction · 0.92
ErrorFunction · 0.92
CodeTypeAlias · 0.92
serverNewPayloadFunction · 0.85
setORCAMetricsFunction · 0.85
GetResponseSizeMethod · 0.80
GetOrcaPerQueryReportMethod · 0.80
GetResponseStatusMethod · 0.45

Tested by

no test coverage detected