Skip to content

Commit

Permalink
return an error when max retry is reached in executeMethod()
Browse files Browse the repository at this point in the history
  • Loading branch information
ericychoi committed Nov 21, 2016
1 parent 0cd90f4 commit daf976a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions api.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"bytes"
"encoding/base64"
"encoding/hex"
"errors"
"fmt"
"io"
"io/ioutil"
Expand Down Expand Up @@ -448,6 +449,8 @@ func (c Client) executeMethod(method string, metadata requestMetadata) (res *htt
// Indicate to our routine to exit cleanly upon return.
defer close(doneCh)

var retryCount int

// Blank indentifier is kept here on purpose since 'range' without
// blank identifiers is only supported since go1.4
// https://golang.org/doc/go1.4#forrange.
Expand Down Expand Up @@ -476,6 +479,7 @@ func (c Client) executeMethod(method string, metadata requestMetadata) (res *htt
}

// Initiate the request.
retryCount++
res, err = c.do(req)
if err != nil {
// For supported network errors verify.
Expand Down Expand Up @@ -528,6 +532,11 @@ func (c Client) executeMethod(method string, metadata requestMetadata) (res *htt
// For all other cases break out of the retry loop.
break
}

if retryCount >= MaxRetry {
err = errors.New("Max retry reached")
}

return res, err
}

Expand Down

0 comments on commit daf976a

Please sign in to comment.