Skip to content
This repository has been archived by the owner on Apr 15, 2024. It is now read-only.

Commit

Permalink
chore: better log (#303)
Browse files Browse the repository at this point in the history
  • Loading branch information
rach-id authored Apr 26, 2023
1 parent 6c60139 commit 72e2b47
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion helpers/retrier.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func NewRetrier(logger tmlog.Logger, retriesNumber int, baseDelay time.Duration)
// calculated using the `NextTick(retryCount)` method.
// Returns the final execution error if all retries failed.
func (r Retrier) Retry(ctx context.Context, retryMethod func() error) error {
r.logger.Info("trying to recover from error...")
var err error
for i := 0; i < r.retriesNumber; i++ {
nextTick := time.NewTimer(r.NextTick(i))
Expand All @@ -42,7 +43,7 @@ func (r Retrier) Retry(ctx context.Context, retryMethod func() error) error {
r.logger.Info("succeeded", "retries_number", i)
return nil
}
r.logger.Error("failed to process", "retry", i, "err", err)
r.logger.Error("failed attempt", "retry", i, "err", err)
}
}
return err
Expand Down
3 changes: 2 additions & 1 deletion relayer/relayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ func (r *Relayer) Start(ctx context.Context) error {
processFunc,
)
if err != nil {
// if an error occurs, retry few times before exiting
// if an error occurs, retry a few times before exiting
r.logger.Error(err.Error())
err = r.Retrier.Retry(ctx, processFunc)
if err != nil {
return err
Expand Down

0 comments on commit 72e2b47

Please sign in to comment.