Documentation ¶
Index ¶
- func BackOffDelayPolicy(attempts uint, _ error, retryConfig *Config) time.Duration
- func DefaultDelayPolicy(_ uint, _ error, _ *Config) time.Duration
- func Delay(attempts uint, err error, retryConfig *Config) time.Duration
- func FixedDelayPolicy(_ uint, _ error, retryConfig *Config) time.Duration
- func RandomDelayPolicy(_ uint, _ error, retryConfig *Config) time.Duration
- type Config
- type DelayPolicyFunc
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BackOffDelayPolicy ¶
BackOffDelayPolicy is a DelayPolicyFunc which exponentially increases delay between consecutive retries, if the retryConfig.Delay less than or equal to 0, the final delay is 0
func DefaultDelayPolicy ¶
DefaultDelayPolicy is a DelayPolicyFunc which keep 0 delay in all iterations
func Delay ¶
Delay generate the delay time required for the current retry config, if the retryConfig.DelayPolicy == nil, the final delay is 0
func FixedDelayPolicy ¶
FixedDelayPolicy is a DelayPolicyFunc which keeps delay the same through all iterations
Types ¶
type Config ¶
type Config struct { // The maximum number of call attempt times, including the initial call MaxAttemptTimes uint // Initial retry delay time Delay time.Duration // Maximum retry delay time. When the retry time increases beyond this time, // this configuration will limit the upper limit of waiting time MaxDelay time.Duration // The maximum jitter time, which takes effect when the delay policy is configured as RandomDelay MaxJitter time.Duration // Delay strategy, which can combine multiple delay strategies. such as CombineDelay(BackOffDelayPolicy, RandomDelayPolicy) or BackOffDelayPolicy,etc DelayPolicy DelayPolicyFunc }
Config All configurations related to retry
type DelayPolicyFunc ¶
DelayPolicyFunc signature of delay policy function is called to return the delay of retry
func CombineDelay ¶
func CombineDelay(delays ...DelayPolicyFunc) DelayPolicyFunc
CombineDelay return DelayPolicyFunc, which combines the optional DelayPolicyFunc into a new DelayPolicyFunc
type Option ¶
type Option struct {
F func(o *Config)
}
Option is the only struct that can be used to set Retry Config.
func WithDelayPolicy ¶
func WithDelayPolicy(delayPolicy DelayPolicyFunc) Option
WithDelayPolicy set DelayPolicy.
func WithMaxAttemptTimes ¶
WithMaxAttemptTimes set WithMaxAttemptTimes , including the first call.
func WithMaxJitter ¶
WithMaxJitter set MaxJitter.