Documentation ¶
Index ¶
- Constants
- Variables
- func Disable(err error) error
- func Retryable(err error) bool
- type Policy
- func (retry Policy) MaxDelay() time.Duration
- func (policy Policy) Retrier() Retrier
- func (policy Policy) RetrierContext(ctx context.Context) Retrier
- func (policy Policy) Run(f func() error) (err error)
- func (policy Policy) RunContext(ctx context.Context, f func() error) (err error)
- func (retry Policy) Step(step *int, delay *time.Duration) error
- func (retry Policy) StepN(n int) (delay time.Duration, err error)
- func (retry Policy) WithDefaults() Policy
- type Retrier
Constants ¶
View Source
const RetrierMaxDelayCoeff = 20
Variables ¶
View Source
var ErrDeadlineExceeded = errors.New("deadline exceeded")
View Source
var ErrMaxAttemptsExceeded = errors.New("max attempts exceeded")
Functions ¶
Types ¶
type Policy ¶
type Policy struct { Attempts int `json:"attempts,omitempty" yaml:"attempts,omitempty"` // The maximum number of retries. Backoff util.Duration `json:"backoff,omitempty" yaml:"backoff,omitempty"` // The base delay between retries. Timeout util.Duration `json:"timeout,omitempty" yaml:"timeout,omitempty"` // The maximum time to wait for a retry. }
func (Policy) RetrierContext ¶
Creates a retries with the given policy and context
func (Policy) RunContext ¶
Convenience function for running a function with a retry policy and context
func (Policy) WithDefaults ¶ added in v0.3.2
type Retrier ¶
type Retrier struct { Context context.Context Policy Policy Step int Delay time.Duration Deadline time.Time }
func (*Retrier) ConsumeAny ¶
Tries to consume the error, and if it can't returns the error
Click to show internal directories.
Click to hide internal directories.