grpc: add ConnectionInfo to client's ResponseHeaders and Trailers - #2802
Conversation
…he response stream ends
|
@arjan-bal - I had to merge in the cancellation changes that you recently submitted. I'm a little uncertain about the tonic behavior if we call In these cases, IIUC tonic itself should send a |
ejona86
left a comment
There was a problem hiding this comment.
Didn't have time to look at it deeply.
Tonic doesn't seem to couple the request and response streams. When the response stream ends, the request stream is left uninterrupted. I verified this by writing an H2 server that immediately sends response headers, a message, and trailers (with EOS) without sending a At the gRPC layer, cancellation is triggered when the We could modify the |
Maybe. But the behavior I'm describing is a standard gRPC-over-h2 behavior. The library on both sides should send a RST_STREAM when the server ends the stream and the client hasn't half-closed already. There is no reason to allow the client to keep sending requests, as the server will discard them (or should, anyway - it's unclear from your tests whether a tonic server would keep delivering request messages even if an h2 server would see them).
I don't think we need/want anything this complicated. The application doesn't need to control this. The library should ideally do the right thing automatically. |
arjan-bal
left a comment
There was a problem hiding this comment.
Some private fields and a comment still use "peer" instead of "connection". Otherwise, LGTM.
| } | ||
|
|
||
| impl ConnectionInfo { | ||
| /// Constructs a new PeerInfo with the given fields. |
There was a problem hiding this comment.
nit: The comment still mentions PeerInfo.
dfawley
left a comment
There was a problem hiding this comment.
Fixed all the lingering "peer" references.
| } | ||
|
|
||
| impl ConnectionInfo { | ||
| /// Constructs a new PeerInfo with the given fields. |
Also: return
ConnectionInfofromTransport::connectinstead ofSecurityInfo(yes, I know I just changed it to produceSecurityInfo) so that the subchannel can set the fullConnectionInfoin Trailers when producing errors locally, since the address of the subchannel may be relevant to those errors.FWIW I wanted to make the subchannel apply an interceptor that could always set
ConnectionInfoin response streams (eitherResponseHeadersor inTrailers-only responses), but because the field is mandatory inResponseHeaders, the transport would need to set it to some default/empty value, which felt wrong. Anything producing aResponseHeadersorTrailersshould ensure theConnectionInfois set correctly.cc @joshuatants as FYI - this is the change that will provide you with the ability to determine the server's address.