interface.go 534 B

123456789101112131415161718192021222324252627282930
  1. package backoff
  2. import (
  3. "context"
  4. "time"
  5. "github.com/lestrrat-go/option"
  6. )
  7. type Option = option.Interface
  8. type Controller interface {
  9. Done() <-chan struct{}
  10. Next() <-chan struct{}
  11. }
  12. type IntervalGenerator interface {
  13. Next() time.Duration
  14. }
  15. // Policy is an interface for the backoff policies that this package
  16. // implements. Users must create a controller object from this
  17. // policy to actually do anything with it
  18. type Policy interface {
  19. Start(context.Context) Controller
  20. }
  21. type Random interface {
  22. Float64() float64
  23. }