...

Source file src/github.com/lestrrat-go/backoff/v2/backoff.go

Documentation: github.com/lestrrat-go/backoff/v2

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

View as plain text