Feat: client method to upload file from master node to slave node
This commit is contained in:
26
pkg/retry/backoff.go
Normal file
26
pkg/retry/backoff.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package retry
|
||||
|
||||
import "time"
|
||||
|
||||
// Backoff used for retry sleep backoff
|
||||
type Backoff interface {
|
||||
Next() bool
|
||||
}
|
||||
|
||||
// ConstantBackoff implements Backoff interface with constant sleep time
|
||||
type ConstantBackoff struct {
|
||||
Sleep time.Duration
|
||||
Max int
|
||||
|
||||
tried int
|
||||
}
|
||||
|
||||
func (c ConstantBackoff) Next() bool {
|
||||
c.tried++
|
||||
if c.tried >= c.Max {
|
||||
return false
|
||||
}
|
||||
|
||||
time.Sleep(c.Sleep)
|
||||
return true
|
||||
}
|
||||
Reference in New Issue
Block a user