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

Struct serverHandlerTransport

internal/transport/handler_server.go:145–177  ·  view source on GitHub ↗

serverHandlerTransport is an implementation of ServerTransport which replies to exactly one gRPC request (exactly one HTTP request), using the net/http.Handler interface. This http.Handler is guaranteed at this point to be speaking over HTTP/2, so it's able to speak valid gRPC.

Source from the content-addressed store, hash-verified

143// at this point to be speaking over HTTP/2, so it's able to speak valid
144// gRPC.
145type serverHandlerTransport struct {
146 rw http.ResponseWriter
147 req *http.Request
148 timeoutSet bool
149 timeout time.Duration
150
151 headerMD metadata.MD
152
153 peer peer.Peer
154
155 closeOnce sync.Once
156 closedCh chan struct{} // closed on Close
157
158 // writes is a channel of code to run serialized in the
159 // ServeHTTP (HandleStreams) goroutine. The channel is closed
160 // when WriteStatus is called.
161 writes chan func()
162
163 // block concurrent WriteStatus calls
164 // e.g. grpc/(*serverStream).SendMsg/RecvMsg
165 writeStatusMu sync.Mutex
166
167 // we just mirror the request content-type
168 contentType string
169 // we store both contentType and contentSubtype so we don't keep recreating them
170 // TODO make sure this is consistent across handler_server and http2_server
171 contentSubtype string
172
173 stats stats.Handler
174 logger *grpclog.PrefixLogger
175
176 bufferPool mem.BufferPool
177}
178
179func (ht *serverHandlerTransport) Close(err error) {
180 ht.closeOnce.Do(func() {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected