Exports recoverable error (#7689)

Signed-off-by: Joe Elliott <number101010@gmail.com>
This commit is contained in:
Joe Elliott 2020-07-29 13:08:25 -04:00 committed by GitHub
parent 48e3473b15
commit 04b028f1e6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 5 deletions

View file

@ -140,7 +140,7 @@ func NewWriteClient(name string, conf *ClientConfig) (WriteClient, error) {
}, nil
}
type recoverableError struct {
type RecoverableError struct {
error
}
@ -177,7 +177,7 @@ func (c *client) Store(ctx context.Context, req []byte) error {
if err != nil {
// Errors from client.Do are from (for example) network errors, so are
// recoverable.
return recoverableError{err}
return RecoverableError{err}
}
defer func() {
io.Copy(ioutil.Discard, httpResp.Body)
@ -193,7 +193,7 @@ func (c *client) Store(ctx context.Context, req []byte) error {
err = errors.Errorf("server returned HTTP status %s: %s", httpResp.Status, line)
}
if httpResp.StatusCode/100 == 5 {
return recoverableError{err}
return RecoverableError{err}
}
return err
}

View file

@ -49,7 +49,7 @@ func TestStoreHTTPErrorHandling(t *testing.T) {
},
{
code: 500,
err: recoverableError{errors.New("server returned HTTP status 500 Internal Server Error: " + longErrMessage[:maxErrMsgLen])},
err: RecoverableError{errors.New("server returned HTTP status 500 Internal Server Error: " + longErrMessage[:maxErrMsgLen])},
},
}

View file

@ -902,7 +902,7 @@ func (s *shards) sendSamplesWithBackoff(ctx context.Context, samples []prompb.Ti
if err != nil {
// If the error is unrecoverable, we should not retry.
if _, ok := err.(recoverableError); !ok {
if _, ok := err.(RecoverableError); !ok {
return err
}