Documentation
¶
Overview ¶
Package retry provides retry policies for activities.
Index ¶
- type Builder
- func (b *Builder) Build() *Policy
- func (b *Builder) WithInitialInterval(d time.Duration) *Builder
- func (b *Builder) WithJitter(factor float64) *Builder
- func (b *Builder) WithMaxAttempts(n int) *Builder
- func (b *Builder) WithMaxInterval(d time.Duration) *Builder
- func (b *Builder) WithMultiplier(m float64) *Builder
- func (b *Builder) WithNonRetryableErrors(errs ...error) *Builder
- type Policy
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder provides a fluent API for building policies.
func (*Builder) WithInitialInterval ¶
WithInitialInterval sets the initial retry interval.
func (*Builder) WithJitter ¶
WithJitter sets the randomization factor.
func (*Builder) WithMaxAttempts ¶
WithMaxAttempts sets the maximum number of attempts.
func (*Builder) WithMaxInterval ¶
WithMaxInterval sets the maximum retry interval.
func (*Builder) WithMultiplier ¶
WithMultiplier sets the backoff multiplier.
func (*Builder) WithNonRetryableErrors ¶
WithNonRetryableErrors sets errors that should not trigger retries.
type Policy ¶
type Policy struct {
// MaxAttempts is the maximum number of attempts (including the first).
// 0 means no limit.
MaxAttempts int
// InitialInterval is the delay before the first retry.
InitialInterval time.Duration
// MaxInterval is the maximum delay between retries.
MaxInterval time.Duration
// Multiplier is the factor by which the interval increases.
Multiplier float64
// RandomizationFactor adds jitter to the delay.
// A value of 0.5 means the actual delay will be within [delay * 0.5, delay * 1.5].
RandomizationFactor float64
// NonRetryableErrors is a list of errors that should not be retried.
// Errors are matched using errors.Is.
NonRetryableErrors []error
}
Policy defines the retry behavior for activities.
func DefaultPolicy ¶
func DefaultPolicy() *Policy
DefaultPolicy returns a sensible default retry policy.
func Exponential ¶
Exponential returns an exponential backoff policy.
Click to show internal directories.
Click to hide internal directories.