This pull request adds support for different backoff strategies (sequential, logarithmic, exponential) and optional jitter to the @retry decorator, addressing the need for more flexible retry mechanisms as described in issue #3.
Summary of Changes
Backoff Strategies: Implemented sequential, logarithmic, and exponential backoff strategies.
Jitter: Added optional jitter to backoff intervals to help prevent the thundering herd problem.
Documentation: Updated the README.md to document these new features.
Tests: Added unit tests for the new backoff strategies and jitter functionality.
Backoff Strategies
The @retry decorator now supports the following backoff strategies:
Sequential: Linear backoff, incrementing the wait time by a fixed amount each retry.
Logarithmic: Logarithmic backoff, using the natural logarithm to increment the wait time.
Exponential: Exponential backoff, doubling the wait time each retry.
Jitter
An optional jitter parameter has been added to introduce a random amount of time to each backoff interval, helping to mitigate the thundering herd problem.
Usage
Here is an example of how to use the updated @retry decorator:
This pull request adds support for different backoff strategies (sequential, logarithmic, exponential) and optional jitter to the
@retry
decorator, addressing the need for more flexible retry mechanisms as described in issue #3.Summary of Changes
Backoff Strategies
The
@retry
decorator now supports the following backoff strategies:Jitter
An optional
jitter
parameter has been added to introduce a random amount of time to each backoff interval, helping to mitigate the thundering herd problem.Usage
Here is an example of how to use the updated
@retry
decorator:Tests
Unit tests have been added to cover:
These changes improve the flexibility and robustness of the
@refry.retry
decorator, making it suitable for a wider range of use cases.Issue Fixed
This pull request fixes issue #3 (except the multiple types of server errors/exceptions)
Checklist
Thank you for reviewing this pull request. @pydanny I look forward to your feedback.