1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
package backoff
// Null creates a new NullPolicy object
func Null() Policy {
return NewNull()
}
// Constant creates a new ConstantPolicy object
func Constant(options ...Option) Policy {
return NewConstantPolicy(options...)
}
// Constant creates a new ExponentialPolicy object
func Exponential(options ...ExponentialOption) Policy {
return NewExponentialPolicy(options...)
}
// Continue is a convenience function to check when we can fire
// the next invocation of the desired backoff code
//
// for backoff.Continue(c) {
// ... your code ...
// }
func Continue(c Controller) bool {
select {
case <-c.Done():
return false
case _, ok := <-c.Next():
return ok
}
}
|