ClientStream implements streaming functionality for a gRPC client.
| 37 | |
| 38 | // ClientStream implements streaming functionality for a gRPC client. |
| 39 | type ClientStream struct { |
| 40 | Stream // Embed for common stream functionality. |
| 41 | |
| 42 | ct *http2Client |
| 43 | done chan struct{} // closed at the end of stream to unblock writers. |
| 44 | doneFunc func() // invoked at the end of stream. |
| 45 | |
| 46 | headerChan chan struct{} // closed to indicate the end of header metadata. |
| 47 | header metadata.MD // the received header metadata |
| 48 | |
| 49 | status *status.Status // the status error received from the server |
| 50 | |
| 51 | // Non-pointer fields are at the end to optimize GC allocations. |
| 52 | |
| 53 | // headerValid indicates whether a valid header was received. Only |
| 54 | // meaningful after headerChan is closed (always call waitOnHeader() before |
| 55 | // reading its value). |
| 56 | headerValid bool |
| 57 | |
| 58 | nonGRPCStatus *status.Status // the initial status from the non-gRPC response header, finalized with collected data before closing. |
| 59 | nonGRPCDataBuf []byte // stores the data of a non-gRPC response. |
| 60 | |
| 61 | noHeaders bool // set if the client never received headers (set only after the stream is done). |
| 62 | headerChanClosed uint32 // set when headerChan is closed. Used to avoid closing headerChan multiple times. |
| 63 | bytesReceived atomic.Bool // indicates whether any bytes have been received on this stream |
| 64 | unprocessed atomic.Bool // set if the server sends a refused stream or GOAWAY including this stream |
| 65 | statsHandler stats.Handler // nil for internal streams (e.g., health check, ORCA) where telemetry is not supported. |
| 66 | } |
| 67 | |
| 68 | func (s *ClientStream) startNonGRPCDataCollection(st *status.Status) { |
| 69 | s.nonGRPCStatus = st |
nothing calls this directly
no outgoing calls
no test coverage detected