go-playground / backoff Goto Github PK
View Code? Open in Web Editor NEW:bowtie: Backoff uses an exponential backoff algorithm to backoff between retries with optional auto-tuning functionality.
License: MIT License
:bowtie: Backoff uses an exponential backoff algorithm to backoff between retries with optional auto-tuning functionality.
License: MIT License
I've been reviewing the code as you requested, here are some feedback:
https://github.com/go-playground/backoff/blob/master/backoff.go#L115
How did you come up with the factor computation?
How about just making it configurable?
In practice "2" is used very often, so the delay doubles every attempt.
https://github.com/go-playground/backoff/blob/master/backoff.go#L99
The backoff strategy doesn't add any jitter, if you take a look at https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/ they demonstrate how adding randomness to the backoff decreases time-to-success as well as the number of retries needed to complete the operation.
https://github.com/go-playground/backoff/blob/master/backoff.go#L13
Taking a dependency just for this one line of code seems a bit overkill.
In my experience, backoff management is often very dependent on the program, for example we have cases where we need to store the backoff state machine in a database to survive restarts of the service. In this case this package wouldn't help. Exposing more primitives that allow programs to build and manage their own backoffs could be helpful (for example, functions to compute the next retry times with various strategies).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.