2016-04-05 22:04:37 +03:00
|
|
|
package client
|
|
|
|
|
|
|
|
import (
|
2018-03-03 14:53:52 +03:00
|
|
|
"context"
|
2016-04-05 22:04:37 +03:00
|
|
|
"time"
|
2020-02-02 23:32:55 +03:00
|
|
|
|
2020-08-19 17:47:17 +03:00
|
|
|
"github.com/unistack-org/micro/v3/util/backoff"
|
2016-04-05 22:04:37 +03:00
|
|
|
)
|
|
|
|
|
2020-11-03 01:08:23 +03:00
|
|
|
// BackoffFunc is the backoff call func
|
2016-04-05 22:04:37 +03:00
|
|
|
type BackoffFunc func(ctx context.Context, req Request, attempts int) (time.Duration, error)
|
|
|
|
|
|
|
|
func exponentialBackoff(ctx context.Context, req Request, attempts int) (time.Duration, error) {
|
2020-02-02 23:32:55 +03:00
|
|
|
return backoff.Do(attempts), nil
|
2016-04-05 22:04:37 +03:00
|
|
|
}
|