Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support backoff retry strategy in Retry.go #837

Open
isopropylcyanide opened this issue Aug 22, 2021 · 0 comments
Open

Support backoff retry strategy in Retry.go #837

isopropylcyanide opened this issue Aug 22, 2021 · 0 comments

Comments

@isopropylcyanide
Copy link

isopropylcyanide commented Aug 22, 2021

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.
@isopropylcyanide isopropylcyanide changed the title Support Backoff retry strategy in Retry.go Support backoff retry strategy in Retry.go Aug 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant