From 87d763598f582781364b1662ad1af702f4fb6e39 Mon Sep 17 00:00:00 2001 From: Edwin Date: Tue, 21 Nov 2023 17:59:25 +0800 Subject: [PATCH] pkg/exchange: use backoff retry --- pkg/exchange/bybit/stream.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pkg/exchange/bybit/stream.go b/pkg/exchange/bybit/stream.go index 475d4bbd9..3b6166194 100644 --- a/pkg/exchange/bybit/stream.go +++ b/pkg/exchange/bybit/stream.go @@ -11,9 +11,9 @@ import ( "golang.org/x/time/rate" "github.com/c9s/bbgo/pkg/exchange/bybit/bybitapi" + "github.com/c9s/bbgo/pkg/exchange/retry" "github.com/c9s/bbgo/pkg/fixedpoint" "github.com/c9s/bbgo/pkg/types" - "github.com/c9s/bbgo/pkg/util" ) const ( @@ -351,11 +351,9 @@ func (s *Stream) handleAuthEvent() { var balnacesMap types.BalanceMap var err error - err = util.Retry(ctx, 10, 300*time.Millisecond, func() error { + err = retry.GeneralBackoff(ctx, func() error { balnacesMap, err = s.streamDataProvider.QueryAccountBalances(ctx) return err - }, func(err error) { - log.WithError(err).Error("failed to call query account balances") }) if err != nil { log.WithError(err).Error("no more attempts to retrieve balances")