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

Make the first exp of retry with backoff be 0 #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lahiguera
Copy link

Context:

Previously the first exponent used to calculate the first waiting
time when retrying using the expoential backoff algorithm with
full jitter was 1, i.e. 2**1 was used instead of 2**0. This made
the first waiting time longer (only potentially because of jitter)
than what it's supposed to be.

Also previously the tests in retry_test.go that relied on
patternTimer were not actually testing anything, since the Run
method of such struct prevented the recording of the waiting times
because prevExecution was always equal to time.Time{}.

This PR fixes the issues mentioned above.

Context:
--------

Previously the first exponent used to calculate the first waiting
time when retrying using the expoential backoff algorithm with
full jitter was 1, i.e. 2**1 was used instead of 2**0. This made
the first waiting time longer (only potentially because of jitter)
than what it's supposed to be.

Also previously the tests in `retry_test.go` that relied on
`patternTimer` were not actually testing anything, since the `Run`
method of such struct preventing the recording of the waiting times
because `prevExecution` was always equal to time.Time{}.

This PR fixes the issues mentioned above.
@lahiguera lahiguera requested a review from slok as a code owner October 20, 2020 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant