File: backoff.go

package info (click to toggle)
golang-github-coreos-pkg 3-1~bpo8%2B1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 320 kB
  • sloc: sh: 30; makefile: 3
file content (15 lines) | stat: -rw-r--r-- 189 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
package timeutil

import (
	"time"
)

func ExpBackoff(prev, max time.Duration) time.Duration {
	if prev == 0 {
		return time.Second
	}
	if prev > max/2 {
		return max
	}
	return 2 * prev
}