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

Fix ExponentialStrategy calculation and update tests #19

Merged
merged 1 commit into from
Aug 29, 2024

Conversation

yamadashy
Copy link
Contributor

@yamadashy yamadashy commented Aug 21, 2024

Fix: #18

This PR addresses the issue #18 where the ExponentialStrategy was not correctly calculating the wait time for the first attempt. The changes include:

Changes made:

public function getWaitTime($attempt)
{
    return (int) ($this->base * (pow(2, $attempt - 1)));
}

This new implementation ensures that:

  • The first attempt (attempt = 1) returns the base wait time
  • Subsequent attempts follow the exponential backoff pattern correctly

Example with base time of 100ms:

  • 1st attempt: 100ms
  • 2nd attempt: 200ms
  • 3rd attempt: 400ms
  • 4th attempt: 800ms
  • ...

Potential impacts:

This change will affect the behavior of the ExponentialStrategy, particularly for the first attempt. Users who were relying on the previous behavior may need to adjust their expectations or configurations.

What I've done:

  • PHPUnit locally (all tests passing)

I've tested this locally and everything looks good. Would really appreciate if you could take a look when you have a moment. Let me know if you need anything else!

@jszobody jszobody merged commit cfbc47e into stechstudio:master Aug 29, 2024
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.

Unexpected behavior in ExponentialStrategy
2 participants