mirror of
https://github.com/davegallant/vpngate.git
synced 2025-08-07 09:02:31 +00:00
Strip out quotes (#97)
* Add Retry function * Strip out quotations from csv
This commit is contained in:
18
pkg/util/retry.go
Normal file
18
pkg/util/retry.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"time"
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
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)
|
||||
time.Sleep(delay)
|
||||
}
|
||||
return err
|
||||
}
|
Reference in New Issue
Block a user