mirror of
https://github.com/c9s/bbgo.git
synced 2024-09-20 08:11:08 +00:00
backoff: add default timeout to backoff.RetryGeneral
This commit is contained in:
parent
6eaacd63a8
commit
fb95072e5b
|
@ -2,6 +2,7 @@ package backoff
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/cenkalti/backoff/v4"
|
"github.com/cenkalti/backoff/v4"
|
||||||
)
|
)
|
||||||
|
@ -9,7 +10,10 @@ import (
|
||||||
var MaxRetries uint64 = 101
|
var MaxRetries uint64 = 101
|
||||||
|
|
||||||
// RetryGeneral retries operation with max retry times 101 and with the exponential backoff
|
// RetryGeneral retries operation with max retry times 101 and with the exponential backoff
|
||||||
func RetryGeneral(ctx context.Context, op backoff.Operation) (err error) {
|
func RetryGeneral(parent context.Context, op backoff.Operation) (err error) {
|
||||||
|
ctx, cancel := context.WithTimeout(parent, 15*time.Minute)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
err = backoff.Retry(op, backoff.WithContext(
|
err = backoff.Retry(op, backoff.WithContext(
|
||||||
backoff.WithMaxRetries(
|
backoff.WithMaxRetries(
|
||||||
backoff.NewExponentialBackOff(),
|
backoff.NewExponentialBackOff(),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user