8000 🚀 v3 Request: Retry Mechanism · Issue #1840 · gofiber/fiber · GitHub 8000
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
🚀 v3 Request: Retry Mechanism #1840
Closed
@gozeloglu

Description

@gozeloglu

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

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0