Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backoffer ¶
type Backoffer interface { Backoff(fn func() error) error BackoffCtx(ctx context.Context, fn func(context.Context) error) error }
Backoffer is an interface to abstract the Runner type into just a the backoff call.
type NoopBackoff ¶
type NoopBackoff struct{}
NoopBackoff is a backoff that is a noop for the backoff. Only calls the func provided to the backoff calls.
func (NoopBackoff) Backoff ¶
func (n NoopBackoff) Backoff(fn func() error) error
Backoff is a backoff runner.
func (NoopBackoff) BackoffCtx ¶
BackoffCtx is a backoff runner that may be interrupted via the provided context.
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner is a backoff runner that will run a backoff func, safe for concurrent use, and provides DI for a backoff callsites.
func New ¶
func New(opts ...RunnerOptFn) Runner
New returns a runner with the defined options. If no options are given, then the new runner is given the defaults for initial and max backoff as well as max calls. The defaults being:
InitBackoff: 1 second MaxBackoff: 1 minute MaxCalls: 10 Jitter: false
func (Runner) BackoffCtx ¶
BackoffCtx runs the given func in a backoff loop defined by the runner type.
func (Runner) New ¶
func (r Runner) New(opts ...RunnerOptFn) Runner
New allows one to create a new runner, with any options, from an existing runner type.
type RunnerOptFn ¶
RunnerOptFn is a functional option to set the
func InitBackoff ¶
func InitBackoff(i time.Duration) RunnerOptFn
InitBackoff sets the runners initial backoff time.
func Jitter ¶
func Jitter() RunnerOptFn
Jitter sets the Backoff method to jitter the backoff duration.
func MaxBackoff ¶
func MaxBackoff(m time.Duration) RunnerOptFn
MaxBackoff sets the runners max backoff time.