Refactor codebase

This commit is contained in:
2026-02-16 08:11:49 -05:00
parent 323709b0a1
commit bb88db92c1
9 changed files with 197 additions and 166 deletions

View File

@@ -2,17 +2,18 @@ package util
import (
"time"
"github.com/rs/zerolog/log"
)
func Retry(attempts int, delay time.Duration,fn func() error) error {
func Retry(attempts int, delay time.Duration, fn func() error) error {
var err error
for i := 0; i < attempts; i++ {
if err = fn(); err == nil {
return nil
}
log.Error().Msgf("Retrying after %d seconds. An error occured: %s", delay, err)
log.Error().Msgf("Retrying after %v. An error occurred: %s", delay, err)
time.Sleep(delay)
}
return err
}
}