Documentation ¶
Overview ¶
* Copyright (C) 2020-2022 Arm Limited or its affiliates and Contributors. All rights reserved. * SPDX-License-Identifier: Apache-2.0
Index ¶
- func RetryIf(ctx context.Context, logger logr.Logger, retryPolicy *RetryPolicyConfiguration, ...) error
- func RetryOnError(ctx context.Context, logger logr.Logger, retryPolicy *RetryPolicyConfiguration, ...) error
- type RetryPolicyConfiguration
- func DefaultBasicRetryPolicyConfiguration() *RetryPolicyConfiguration
- func DefaultExponentialBackoffRetryPolicyConfiguration() *RetryPolicyConfiguration
- func DefaultLinearBackoffRetryPolicyConfiguration() *RetryPolicyConfiguration
- func DefaultNoRetryPolicyConfiguration() *RetryPolicyConfiguration
- func DefaultRobustRetryPolicyConfiguration() *RetryPolicyConfiguration
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RetryIf ¶
func RetryIf(ctx context.Context, logger logr.Logger, retryPolicy *RetryPolicyConfiguration, fn func() error, msgOnRetry string, retryConditionFn func(err error) bool) error
RetryIf will retry fn when the value returned from retryConditionFn is true
func RetryOnError ¶
func RetryOnError(ctx context.Context, logger logr.Logger, retryPolicy *RetryPolicyConfiguration, fn func() error, msgOnRetry string, retriableErr ...error) error
RetryOnError allows the caller to retry fn when the error returned by fn is retriable as in of the type specified by retriableErr. backoff defines the maximum retries and the wait interval between two retries.
Types ¶
type RetryPolicyConfiguration ¶
type RetryPolicyConfiguration struct { // Enabled specifies whether this retry policy is enabled or not. If not, no retry will be performed. Enabled bool `mapstructure:"enabled"` // RetryMax represents the maximum number of retries RetryMax int `mapstructure:"max_retry"` // RetryAfterDisabled tells the client not to consider the `Retry-After` header (https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After) returned by server. RetryAfterDisabled bool `mapstructure:"retry_after_disabled"` // RetryWaitMin specifies the minimum time to wait between retries. RetryWaitMin time.Duration // RetryWaitMax represents the maximum time to wait (only necessary if backoff is enabled). RetryWaitMax time.Duration // BackOffEnabled states whether backoff must be performed during retries (by default, exponential backoff is performed unless LinearBackoff is enabled). BackOffEnabled bool `mapstructure:"backoff_enabled"` // LinearBackOffEnabled forces to perform linear backoff instead of exponential backoff provided BackOffEnabled is set to true. LinearBackOffEnabled bool `mapstructure:"linear_backoff_enabled"` }
func DefaultBasicRetryPolicyConfiguration ¶
func DefaultBasicRetryPolicyConfiguration() *RetryPolicyConfiguration
DefaultBasicRetryPolicyConfiguration defines a configuration for basic retries i.e. retrying straight after a failure for maximum 4 attempts.
func DefaultExponentialBackoffRetryPolicyConfiguration ¶
func DefaultExponentialBackoffRetryPolicyConfiguration() *RetryPolicyConfiguration
DefaultExponentialBackoffRetryPolicyConfiguration defines a configuration for retries with exponential backoff.
func DefaultLinearBackoffRetryPolicyConfiguration ¶
func DefaultLinearBackoffRetryPolicyConfiguration() *RetryPolicyConfiguration
DefaultLinearBackoffRetryPolicyConfiguration defines a configuration for retries with linear backoff.
func DefaultNoRetryPolicyConfiguration ¶
func DefaultNoRetryPolicyConfiguration() *RetryPolicyConfiguration
DefaultNoRetryPolicyConfiguration defines a configuration for no retry being performed.
func DefaultRobustRetryPolicyConfiguration ¶
func DefaultRobustRetryPolicyConfiguration() *RetryPolicyConfiguration
DefaultRobustRetryPolicyConfiguration defines a configuration for basic retries but considering any `Retry-After` being returned by server.
func (*RetryPolicyConfiguration) Validate ¶
func (cfg *RetryPolicyConfiguration) Validate() error