remove local network/range

This commit is contained in:
Matthew R Kasun
2023-02-26 16:28:16 -05:00
parent 3244472481
commit 828b3f7162
20 changed files with 0 additions and 1075 deletions

View File

@@ -1,29 +1,4 @@
package ncutils
import (
"fmt"
"time"
"github.com/gravitl/netmaker/logger"
)
// CheckInInterval - the interval for check-in time in units/minute
const CheckInInterval = 1
// BackOff - back off any function while there is an error
func BackOff(isExponential bool, maxTime int, f interface{}) (interface{}, error) {
// maxTime seconds
startTime := time.Now()
sleepTime := time.Second
for time.Now().Before(startTime.Add(time.Second * time.Duration(maxTime))) {
if result, err := f.(func() (interface{}, error))(); err == nil {
return result, nil
}
time.Sleep(sleepTime)
if isExponential {
sleepTime = sleepTime << 1
}
logger.Log(1, "retrying...")
}
return nil, fmt.Errorf("could not find result")
}