mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-14 19:13:52 +00:00
19 lines
325 B
Go
19 lines
325 B
Go
|
package backoff
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
|
||
|
"github.com/cenkalti/backoff/v4"
|
||
|
)
|
||
|
|
||
|
var MaxRetries uint64 = 101
|
||
|
|
||
|
func RetryGeneric(ctx context.Context, op backoff.Operation) (err error) {
|
||
|
err = backoff.Retry(op, backoff.WithContext(
|
||
|
backoff.WithMaxRetries(
|
||
|
backoff.NewExponentialBackOff(),
|
||
|
MaxRetries),
|
||
|
ctx))
|
||
|
return err
|
||
|
}
|