Skip to content

Implement Deadline for strategies #27

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

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

Conversation

pzmarzly
Copy link

The issue with $STRATEGY.take(n) is that is doesn't take function execution time into consideration. If you use a strategy that retries 100 times, every 10 milliseconds, but you use it against a function that takes 1 second to execute, the total execution time will be 101 seconds (100 * (fn execution + retry interval) = 100 * (1 + 0.01)).

In this PR I'm adding a deadline(max_duration) function, which restricts how much time can a strategy take. It uses Instant clock to count the time since the strategy was created, so it includes the function execution time.

Please tell me what you think.

@pzmarzly pzmarzly force-pushed the deadline-for-strategies branch from eca47ee to bde18ec Compare August 14, 2023 14:37
@naomijub
Copy link

naomijub commented Sep 4, 2024

In case you want to add your contribution or have other suggestions: https://github.com/naomijub/tokio-retry

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.

2 participants