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

Function SetTrailer

server.go:2192–2201  ·  view source on GitHub ↗

SetTrailer sets the trailer metadata that will be sent when an RPC returns. When called more than once, all the provided metadata will be merged. The error returned is compatible with the status package. However, the status code will often not match the RPC status as seen by the client application

(ctx context.Context, md metadata.MD)

Source from the content-addressed store, hash-verified

2190// status code will often not match the RPC status as seen by the client
2191// application, and therefore, should not be relied upon for this purpose.
2192func SetTrailer(ctx context.Context, md metadata.MD) error {
2193 if md.Len() == 0 {
2194 return nil
2195 }
2196 stream := ServerTransportStreamFromContext(ctx)
2197 if stream == nil {
2198 return status.Errorf(codes.Internal, "grpc: failed to fetch the stream from the context %v", ctx)
2199 }
2200 return stream.SetTrailer(md)
2201}
2202
2203// Method returns the method string for the server context. The returned
2204// string is in the format of "/service/method".

Callers 11

setTrailerMetadataMethod · 0.92
startServerMethod · 0.92
TestCanceledStatusMethod · 0.92
UnaryCallMethod · 0.92
startBackendsFunction · 0.92
UnaryCallMethod · 0.92
testDoneLoadsFunction · 0.92
unaryInterceptorFunction · 0.92
UnaryEchoMethod · 0.92
newStatsTestStubServerFunction · 0.92
TestStatusDetailsMethod · 0.92

Calls 4

ErrorfFunction · 0.92
LenMethod · 0.65
SetTrailerMethod · 0.65

Tested by 7

startServerMethod · 0.74
TestCanceledStatusMethod · 0.74
startBackendsFunction · 0.74
UnaryCallMethod · 0.74
testDoneLoadsFunction · 0.74
newStatsTestStubServerFunction · 0.74
TestStatusDetailsMethod · 0.74