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

Struct clientStream

stream.go:574–627  ·  view source on GitHub ↗

clientStream implements a client side Stream.

Source from the content-addressed store, hash-verified

572
573// clientStream implements a client side Stream.
574type clientStream struct {
575 callHdr *transport.CallHdr
576 opts []CallOption
577 callInfo *callInfo
578 cc *ClientConn
579 desc *StreamDesc
580
581 codec baseCodec
582 compressorV0 Compressor
583 compressorV1 encoding.Compressor
584
585 cancel context.CancelFunc // cancels all attempts
586
587 sentLast bool // sent an end stream
588
589 receivedFirstMsg bool // set after the first message is received
590
591 methodConfig *MethodConfig
592
593 ctx context.Context // the application's context, wrapped by stats/tracing
594
595 retryThrottler *retryThrottler // The throttler active when the RPC began.
596
597 binlogs []binarylog.MethodLogger
598 // serverHeaderBinlogged is a boolean for whether server header has been
599 // logged. Server header will be logged when the first time one of those
600 // happens: stream.Header(), stream.Recv().
601 //
602 // It's only read and used by Recv() and Header(), so it doesn't need to be
603 // synchronized.
604 serverHeaderBinlogged bool
605
606 mu sync.Mutex
607 firstAttempt bool // if true, transparent retry is valid
608 numRetries int // exclusive of transparent retry attempt(s)
609 numRetriesSincePushback int // retries since pushback; to reset backoff
610 finished bool // TODO: replace with atomic cmpxchg or sync.Once?
611 // attempt is the active client stream attempt.
612 // The only place where it is written is the newAttemptLocked method and this method never writes nil.
613 // So, attempt can be nil only inside newClientStream function when clientStream is first created.
614 // One of the first things done after clientStream's creation, is to call newAttemptLocked which either
615 // assigns a non nil value to the attempt or returns an error. If an error is returned from newAttemptLocked,
616 // then newClientStream calls finish on the clientStream and returns. So, finish method is the only
617 // place where we need to check if the attempt is nil.
618 attempt *csAttempt
619 // TODO(hedging): hedging will have multiple attempts simultaneously.
620 committed bool // active attempt committed for retry?
621 onCommit func()
622 replayBuffer []replayOp // operations to replay on retry
623 replayBufferSize int // current size of replayBuffer
624 // nameResolutionDelay indicates if there was a delay in the name resolution.
625 // This field is only valid on client side, it's always false on server side.
626 nameResolutionDelay bool
627}
628
629type replayOp struct {
630 op func(a *csAttempt) error

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected