From 04b028f1e611a7887cbfc54585d965eb2cc5e7e6 Mon Sep 17 00:00:00 2001 From: Joe Elliott Date: Wed, 29 Jul 2020 13:08:25 -0400 Subject: [PATCH] Exports recoverable error (#7689) Signed-off-by: Joe Elliott --- storage/remote/client.go | 6 +++--- storage/remote/client_test.go | 2 +- storage/remote/queue_manager.go | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/storage/remote/client.go b/storage/remote/client.go index 11fc05eb4..be68cb3d8 100644 --- a/storage/remote/client.go +++ b/storage/remote/client.go @@ -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 } diff --git a/storage/remote/client_test.go b/storage/remote/client_test.go index 59e2128b4..22942e3f3 100644 --- a/storage/remote/client_test.go +++ b/storage/remote/client_test.go @@ -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])}, }, } diff --git a/storage/remote/queue_manager.go b/storage/remote/queue_manager.go index 5c7279df2..6c91e2410 100644 --- a/storage/remote/queue_manager.go +++ b/storage/remote/queue_manager.go @@ -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 }