Documentation ¶
Index ¶
- Constants
- Variables
- func IsStatusCodeRetryable(status *status.Status) bool
- func NewRetryOptionsInterceptor(excludeInternal *uberatomic.Bool) grpc.UnaryClientInterceptor
- type GrpcRetryConfig
- func (g *GrpcRetryConfig) SetBackoffCoefficient(backoffCoefficient float64)
- func (g *GrpcRetryConfig) SetExpirationInterval(expirationInterval time.Duration)
- func (g *GrpcRetryConfig) SetJitter(jitter float64)
- func (g *GrpcRetryConfig) SetMaximumAttempts(maximumAttempts int)
- func (g *GrpcRetryConfig) SetMaximumInterval(maximumInterval time.Duration)
Constants ¶
const ( // UnlimitedMaximumAttempts when maximum attempts is set to this special value, then the number of attempts is unlimited. UnlimitedMaximumAttempts = 0 // UnlimitedInterval when maximum interval is set to this special value, then there is no upper bound on the retry delay. // Should not be used together with unlimited attempts as resulting retry interval can grow to unreasonable values. UnlimitedInterval = 0 // DefaultBackoffCoefficient is default backOffCoefficient for retryPolicy DefaultBackoffCoefficient = 2.0 // DefaultMaximumInterval is default maximum amount of time for an individual retry. DefaultMaximumInterval = 10 * time.Second // DefaultExpirationInterval is default expiration time for all retry attempts. DefaultExpirationInterval = time.Minute // DefaultMaximumAttempts is default maximum number of attempts. DefaultMaximumAttempts = UnlimitedMaximumAttempts // DefaultJitter is a default jitter applied on the backoff interval for delay randomization. DefaultJitter = 0.2 )
Variables ¶
var (
// ConfigKey context key for GrpcRetryConfig
ConfigKey = contextKey{}
)
Functions ¶
func IsStatusCodeRetryable ¶
IsStatusCodeRetryable returns true if error code in the status is retryable.
func NewRetryOptionsInterceptor ¶
func NewRetryOptionsInterceptor(excludeInternal *uberatomic.Bool) grpc.UnaryClientInterceptor
NewRetryOptionsInterceptor creates a new gRPC interceptor that populates retry options for each call based on values provided in the context. The atomic bool is checked each call to determine whether internals are included in retry. If not present or false, internals are assumed to be included.
Types ¶
type GrpcRetryConfig ¶
type GrpcRetryConfig struct {
// contains filtered or unexported fields
}
GrpcRetryConfig defines required configuration for exponential backoff function that is supplied to gRPC retrier.
func NewGrpcRetryConfig ¶
func NewGrpcRetryConfig(initialInterval time.Duration) *GrpcRetryConfig
NewGrpcRetryConfig creates new retry config with specified initial interval and defaults for other parameters. Use SetXXX functions on this config in order to customize values.
func (*GrpcRetryConfig) SetBackoffCoefficient ¶
func (g *GrpcRetryConfig) SetBackoffCoefficient(backoffCoefficient float64)
SetBackoffCoefficient sets rate at which backoff coefficient will change.
func (*GrpcRetryConfig) SetExpirationInterval ¶
func (g *GrpcRetryConfig) SetExpirationInterval(expirationInterval time.Duration)
SetExpirationInterval defines total amount of time that can be used for all retry attempts. Note that this value is ignored if deadline is set on the context.
func (*GrpcRetryConfig) SetJitter ¶
func (g *GrpcRetryConfig) SetJitter(jitter float64)
SetJitter defines level of randomization for each delay interval. For example 0.2 would mex target +- 20%
func (*GrpcRetryConfig) SetMaximumAttempts ¶
func (g *GrpcRetryConfig) SetMaximumAttempts(maximumAttempts int)
SetMaximumAttempts defines maximum total number of retry attempts.
func (*GrpcRetryConfig) SetMaximumInterval ¶
func (g *GrpcRetryConfig) SetMaximumInterval(maximumInterval time.Duration)
SetMaximumInterval defines maximum amount of time between attempts.