Skip to content

Commit

Permalink
Do not stop retrying based on earlier good message from the stream (#313
Browse files Browse the repository at this point in the history
)

- Usually the pattern is to establish a stream and read messages
in the loop until io.EOF. If the server become unavailable after
sending a good message in the stream, the client has to retry from
establish stream and handle the backoff logic.
  • Loading branch information
kartlee committed Apr 23, 2021
1 parent df0f91b commit 3d8607d
Showing 1 changed file with 0 additions and 10 deletions.
10 changes: 0 additions & 10 deletions retry/retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ func StreamClientInterceptor(optFuncs ...CallOption) grpc.StreamClientIntercepto
type serverStreamingRetryingStream struct {
grpc.ClientStream
bufferedSends []interface{} // single message that the client can sen
receivedGood bool // indicates whether any prior receives were successful
wasClosedSend bool // indicates that CloseSend was closed
parentCtx context.Context
callOpts *options
Expand Down Expand Up @@ -209,17 +208,8 @@ func (s *serverStreamingRetryingStream) RecvMsg(m interface{}) error {
}

func (s *serverStreamingRetryingStream) receiveMsgAndIndicateRetry(m interface{}) (bool, error) {
s.mu.RLock()
wasGood := s.receivedGood
s.mu.RUnlock()
err := s.getStream().RecvMsg(m)
if err == nil || err == io.EOF {
s.mu.Lock()
s.receivedGood = true
s.mu.Unlock()
return false, err
} else if wasGood {
// previous RecvMsg in the stream succeeded, no retry logic should interfere
return false, err
}
if isContextError(err) {
Expand Down

0 comments on commit 3d8607d

Please sign in to comment.