Returns nil if a retry was performed and succeeded; error otherwise.
(attempt *csAttempt, lastErr error)
| 781 | |
| 782 | // Returns nil if a retry was performed and succeeded; error otherwise. |
| 783 | func (cs *clientStream) retryLocked(attempt *csAttempt, lastErr error) error { |
| 784 | for { |
| 785 | attempt.finish(toRPCErr(lastErr)) |
| 786 | isTransparent, err := attempt.shouldRetry(lastErr) |
| 787 | if err != nil { |
| 788 | cs.commitAttemptLocked() |
| 789 | return err |
| 790 | } |
| 791 | cs.firstAttempt = false |
| 792 | attempt, err = cs.newAttemptLocked(isTransparent) |
| 793 | if err != nil { |
| 794 | // Only returns error if the clientconn is closed or the context of |
| 795 | // the stream is canceled. |
| 796 | return err |
| 797 | } |
| 798 | // Note that the first op in replayBuffer always sets cs.attempt |
| 799 | // if it is able to pick a transport and create a stream. |
| 800 | if lastErr = cs.replayBufferLocked(attempt); lastErr == nil { |
| 801 | return nil |
| 802 | } |
| 803 | } |
| 804 | } |
| 805 | |
| 806 | func (cs *clientStream) Context() context.Context { |
| 807 | cs.commitAttempt() |
no test coverage detected