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