Add util
This commit is contained in:
14
util/backoff/backoff.go
Normal file
14
util/backoff/backoff.go
Normal file
@@ -0,0 +1,14 @@
|
||||
// Package backoff provides backoff functionality
|
||||
package backoff
|
||||
|
||||
import (
|
||||
"math"
|
||||
"time"
|
||||
)
|
||||
|
||||
func Do(attempts int) time.Duration {
|
||||
if attempts == 0 {
|
||||
return time.Duration(0)
|
||||
}
|
||||
return time.Duration(math.Pow(10, float64(attempts))) * time.Millisecond
|
||||
}
|
Reference in New Issue
Block a user