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

Function unaryInt

orca/call_metrics.go:138–156  ·  view source on GitHub ↗
(smp ServerMetricsProvider)

Source from the content-addressed store, hash-verified

136}
137
138func unaryInt(smp ServerMetricsProvider) func(ctx context.Context, req any, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) {
139 return func(ctx context.Context, req any, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) {
140 // We don't allocate the metric recorder here. It will be allocated the
141 // first time the user calls CallMetricsRecorderFromContext().
142 rw := &recorderWrapper{smp: smp}
143 ctxWithRecorder := newContextWithRecorderWrapper(ctx, rw)
144
145 resp, err := handler(ctxWithRecorder, req)
146
147 // It is safe to access the underlying metric recorder inside the wrapper at
148 // this point, as the user's RPC handler is done executing, and therefore
149 // there will be no more calls to CallMetricsRecorderFromContext(), which is
150 // where the metric recorder is lazy allocated.
151 if rw.r != nil {
152 rw.setTrailerMetadata(ctx)
153 }
154 return resp, err
155 }
156}
157
158func streamInt(smp ServerMetricsProvider) func(srv any, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error {
159 return func(srv any, ss grpc.ServerStream, _ *grpc.StreamServerInfo, handler grpc.StreamHandler) error {

Callers 1

CallMetricsServerOptionFunction · 0.85

Calls 2

setTrailerMetadataMethod · 0.95

Tested by

no test coverage detected