lib: use permanent error instead of context cancellation (#1429)

This commit is contained in:
Ludovic Fernandez 2021-06-11 11:07:38 +02:00 committed by GitHub
parent 9b44e4a262
commit 1dbebce7a9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 9 additions and 21 deletions

View file

@ -2,7 +2,6 @@ package api
import (
"bytes"
"context"
"crypto"
"encoding/json"
"errors"
@ -83,8 +82,6 @@ func (a *Core) retrievablePost(uri string, content []byte, response interface{})
bo.MaxInterval = 5 * time.Second
bo.MaxElapsedTime = 20 * time.Second
ctx, cancel := context.WithCancel(context.Background())
var resp *http.Response
operation := func() error {
var err error
@ -96,8 +93,7 @@ func (a *Core) retrievablePost(uri string, content []byte, response interface{})
return err
}
cancel()
return err
return backoff.Permanent(err)
}
return nil
@ -107,7 +103,7 @@ func (a *Core) retrievablePost(uri string, content []byte, response interface{})
log.Infof("retry due to: %v", err)
}
err := backoff.RetryNotify(operation, backoff.WithContext(bo, ctx), notify)
err := backoff.RetryNotify(operation, bo, notify)
if err != nil {
return resp, err
}