Documentation
¶
Index ¶
- Variables
- type Option
- type Policy
- type Retry
- func (r *Retry) Do(fn func() error) error
- func (r *Retry) SetContext(ctx context.Context) *Retry
- func (r *Retry) SetDelay(delay time.Duration) *Retry
- func (r *Retry) SetLogger(logger logger) *Retry
- func (r *Retry) SetMaxAttempts(maxAttempts int) *Retry
- func (r *Retry) SetOnFailedFn(fn func()) *Retry
- func (r *Retry) SetOnSuccessFn(fn func()) *Retry
- func (r *Retry) SetPolicy(policy Policy) *Retry
Constants ¶
This section is empty.
Variables ¶
var ( ErrRetry = errors.New("retry") ErrExit = errors.New("exit") )
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(*Retry)
func WithContext ¶
WithContext sets the ctx for Infinite policy retry
func WithLogger ¶
func WithLogger(logger logger) Option
WithLogger sets the logger for the Retry instance
func WithMaxAttempts ¶
WithMaxAttempts sets the maximum number of attempts
func WithOnFailedFn ¶
func WithOnFailedFn(fn func()) Option
WithOnFailedFn sets the function to be called on failure
func WithOnSuccessFn ¶
func WithOnSuccessFn(fn func()) Option
WithOnSuccessFn sets the function to be called on success
type Retry ¶
type Retry struct {
// contains filtered or unexported fields
}
Retry represents a retry mechanism
func New ¶
New creates a new Retry instance
maxAttempts: the maximum number of attempts. Default is 5
policy: the retry policy. Default is PolicyBackoff
func (*Retry) SetContext ¶
SetContext sets the ctx for Infinite policy retry
func (*Retry) SetMaxAttempts ¶
SetMaxAttempts sets the maximum number of attempts
func (*Retry) SetOnFailedFn ¶
SetOnFailedFn sets the function to be called on failure
func (*Retry) SetOnSuccessFn ¶
SetOnSuccessFn sets the function to be called on success