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

🚀 v3 Request: Retry Mechanism #1840

Closed
gozeloglu opened this issue Mar 30, 2022 · 5 comments · Fixed by #1972
Closed

🚀 v3 Request: Retry Mechanism #1840

gozeloglu opened this issue Mar 30, 2022 · 5 comments · Fixed by #1972
Assignees
Milestone

Comments

@gozeloglu
Copy link
Contributor

Is your feature request related to a problem?

Describe the solution you'd like
I am planning to add the exponential backoff algorithm. It is a widely used retry policy. Basically, there will be 2 different functions. One is Retry() (or Do() ) method and NextBackoff()(or NextTime()) methods. Of course, there will be some helper methods like NewBackoff(), Reset(). This feature will be flexible. The users can be used Retry() method and everything will be handled by the package. They won't consider details. They will just call the method like this:

backoff.Retry(func() error{
    // Do whatever you want    
    return err
})

Or, maybe some users want to handle the retry part themselves. In this case, we provide all functionalities other than Retry() method like Reset(), NextTime(), Sleep(). They use the package and call the methods like this:

for i := 0; i < n; i++ {
    ...
    next := backoff.NextTime()
    backoff.Sleep(next)
}
...
backoff.Reset()

Also, we can add two options to check the retry count/time with Context and retryCount. In Context usage, we set timeout to context and retry goes until timeout expires. For retryCount usage, we set number of retry step like 10, and the method retries 10 times.

Describe alternatives you've considered
Regular Interval: Waits in regular period of time.
Incremental Intervals: Waiting time is increasing incrementally.
Additional context

@welcome
Copy link

welcome bot commented Mar 30, 2022

Thanks for opening your first issue here! 🎉 Be sure to follow the issue template! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord

@efectn efectn added this to the v3 milestone May 10, 2022
@efectn efectn added this to v3 Jun 5, 2022
@efectn efectn moved this to Todo in v3 Jun 5, 2022
@efectn efectn removed this from v3 Jun 5, 2022
@efectn efectn added this to v3 Jun 5, 2022
@efectn efectn moved this to Todo in v3 Jun 5, 2022
@vishjain
Copy link

vishjain commented Jul 8, 2022

Can I contribute to this issue? Thanks! @ReneWerner87

@ReneWerner87
Copy link
Member

Sure

@gozeloglu
Copy link
Contributor Author

I was expecting to implement this. I mentioned that wanted to implemenet it in discussion section and proposed above solutions. As I remember @ReneWerner87 told me that v3 implementations hasn't been started yet when I asked it.

@ReneWerner87
Copy link
Member

there is the https://github.com/gofiber/fiber/tree/v3-beta branch
you can fork another branch from it and create a pull request for it on the beta branch

Sorry @vishjain gozeloglu has the prerogative and if he has time and desire he should start with it

@efectn efectn moved this from Todo to In Progress in v3 Jul 10, 2022
@efectn efectn linked a pull request Jul 10, 2022 that will close this issue
@efectn efectn closed this as completed Aug 19, 2022
Repository owner moved this from In Progress to Done in v3 Aug 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants