mirror of
https://github.com/go-micro/go-micro.git
synced 2025-11-29 21:47:44 +02:00
15 lines
258 B
Go
15 lines
258 B
Go
|
|
// 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
|
||
|
|
}
|