New backoff (#1153)
* new backoff function * use backoff from util/backoff * remove reset atemts * change comment * fmt
This commit is contained in:
@@ -2,13 +2,13 @@ package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"math"
|
||||
"time"
|
||||
|
||||
"github.com/micro/go-micro/v2/util/backoff"
|
||||
)
|
||||
|
||||
type BackoffFunc func(ctx context.Context, req Request, attempts int) (time.Duration, error)
|
||||
|
||||
// exponential backoff is a function x^e multiplied by a factor of 0.1 second.
|
||||
func exponentialBackoff(ctx context.Context, req Request, attempts int) (time.Duration, error) {
|
||||
return time.Duration(math.Pow(float64(attempts), math.E)) * time.Millisecond * 100, nil
|
||||
return backoff.Do(attempts), nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user