mirror of
https://github.com/rancher/os.git
synced 2025-09-04 00:04:25 +00:00
Added tftp datasource for cloud config.
This commit is contained in:
committed by
niusmallnan
parent
8b75752225
commit
66c5f6130a
35
vendor/github.com/pin/tftp/backoff.go
generated
vendored
Normal file
35
vendor/github.com/pin/tftp/backoff.go
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
package tftp
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
defaultTimeout = 5 * time.Second
|
||||
defaultRetries = 5
|
||||
)
|
||||
|
||||
type backoffFunc func(int) time.Duration
|
||||
|
||||
type backoff struct {
|
||||
attempt int
|
||||
handler backoffFunc
|
||||
}
|
||||
|
||||
func (b *backoff) reset() {
|
||||
b.attempt = 0
|
||||
}
|
||||
|
||||
func (b *backoff) count() int {
|
||||
return b.attempt
|
||||
}
|
||||
|
||||
func (b *backoff) backoff() {
|
||||
if b.handler == nil {
|
||||
time.Sleep(time.Duration(rand.Int63n(int64(time.Second))))
|
||||
} else {
|
||||
time.Sleep(b.handler(b.attempt))
|
||||
}
|
||||
b.attempt++
|
||||
}
|
Reference in New Issue
Block a user