package helpers import ( "math" "time" "git.fjla.uk/owlboard/timetable-mgr/log" "go.uber.org/zap" ) // Implements an exponential backoff strategy and sleeps for a duration calculated as 1 second to the power of (attempt - 1). // The backoff time doubles with each attempt, starting from 1 second for the first attempt. func BackoffDelay(attempt int) { base := time.Second backoff := base * time.Duration(math.Pow(2, float64(attempt-1))) log.Info("Retry backoff", zap.Duration("delay", backoff)) time.Sleep(backoff) }