mirror of
https://github.com/go-micro/go-micro.git
synced 2024-12-24 10:07:04 +02:00
449bcb46fe
* new backoff function * use backoff from util/backoff * remove reset atemts * change comment * fmt
17 lines
363 B
Go
17 lines
363 B
Go
// Package backoff provides backoff functionality
|
|
package backoff
|
|
|
|
import (
|
|
"math"
|
|
"time"
|
|
)
|
|
|
|
// Do is a function x^e multiplied by a factor of 0.1 second.
|
|
// Result is limited to 2 minute.
|
|
func Do(attempts int) time.Duration {
|
|
if attempts > 13 {
|
|
return 2 * time.Minute
|
|
}
|
|
return time.Duration(math.Pow(float64(attempts), math.E)) * time.Millisecond * 100
|
|
}
|