-
Notifications
You must be signed in to change notification settings - Fork 90
Open
Labels
Description
Currently, tchannel-go/retry.go offers RunWithRetry(runCtx context.Context, f RetriableFunc) which is a straight for loop of the func upto retryOpts.MaxAttempts.
It does not offer a way for callers to specify a backoff strategy.
A backoff strategy (such as backoff.Exponential or backoff.FixedDelay) would be useful to not wreak havoc at an unhealthy backend. The current implementation will shoot 1 + 5 (default retries) calls at the backend.
The proposal is to support a backoff strategy in RetryOptions
// RetryOptions are the retry options used to configure RunWithRetry.
type RetryOptions struct {
...
TimeoutPerAttempt time.Duration
BackoffStrategy BackoffStrategy
}var defaultRetryOptions = &RetryOptions{
MaxAttempts: 5,
BackoffStrategy : nil // or fixed or backoff
}
- If BackoffStrategy is nil, the existing behaviour continues.
- If BackoffStrategy is fixed delay, implement a fixed delay between retries
- If BackoffStrategy is exponential, implement an exponentially decaying delay exponentially between retries.
Reactions are currently unavailable